Skip to content

Instantly share code, notes, and snippets.

View tamlyn's full-sized avatar

Tamlyn Rhodes tamlyn

View GitHub Profile
@tamlyn
tamlyn / scrape.js
Last active March 23, 2018 23:37
Scrape statements from First Direct internet banking
//////// CONFIG /////////
// your first direct user name
const username = ''
// your password (the one it asks for characters from)
const password = ''
// your memorable word
const memorable = ''
// set to false if you want to see the browser window as it runs
const headless = true
@tamlyn
tamlyn / cypress.test.js
Created March 8, 2018 11:16
Example Cypress test suite
// a very short Cypress test suite
describe('Admin user', () => {
it('Create posts journey', () => {
const postTitle = 'Hello testing'
cy.get('input[id=title]').type(postTitle)
cy.get('button[title=Create]').click()
cy.get('table tr:last label').should('contain', postTitle)
})
})
@tamlyn
tamlyn / testcafe.test.js
Created March 8, 2018 11:11
Example TestCafe test suite
// a very short TestCafe test suite
fixture('Admin user')
test('Create posts journey', t => {
const postTitle = 'Hello testing'
return t
.typeText(ReactSelector('PostCreator FormControl'), postTitle)
.click(ReactSelector('PostCreator Button'))
.expect(ReactSelector('Post').first().find('label').innerText)
.eql(postTitle)
})
@tamlyn
tamlyn / Readme.md
Last active March 5, 2018 12:00
Redacting fields in GraphQL with Apollo Server

Demo showing that by specifying a resolver for a scalar property, you can override the value.

This is useful for authorization as it means you can centrally check permissions per field. Your general resolvers can return whole objects without caring about which fields the current user may or may not be allowed to see.

@tamlyn
tamlyn / Readme.md
Created November 21, 2017 11:22
Slate Editor + Testcafe + WebKit

Test case

Bug when running Testcafe on Slate Editor inputs in Chrome/Safari

  1. Serve index.html on port 8080, e.g. http-server
  2. Run test, e.g. testcafe chrome test.js

Expected

New text is appended to input

Actual

Keybase proof

I hereby claim:

  • I am tamlyn on github.
  • I am tamlyn (https://keybase.io/tamlyn) on keybase.
  • I have a public key ASDtLiAyqvI_72LatdxQWOQhNvOLwyMJZtFU0PRAywgROAo

To claim this, I am signing this object:

@tamlyn
tamlyn / README.md
Last active March 14, 2018 15:02
Start debugging a running node process

Shows a list of all node processes and lets you select which one you want to debug.

For example

$ debug.sh
1) 73428 node webpack/webpackDevServer.js
2) 73494 node build/dist/server.js

Select which process to debug: █

@tamlyn
tamlyn / pull-modules.sh
Last active December 7, 2016 11:02
Update and build all npm linked modules
pull-modules () {
BASE_DIR=$(pwd)
# find symlinks in node_modules
for MODULE in $(find node_modules -type l -depth 1)
do
cd "$MODULE"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Updating $MODULE ($BRANCH)..."
@tamlyn
tamlyn / README.md
Last active July 7, 2022 09:48
Execution order of Jest/Jasmine test code

Execution order of Jest/Jasmine test code

While tests run in source order, surrounding code does not which can lead to hard to debug issues.

Compare the test file below with the sample output below that and note the order of the log messages.

Key points

  • Any code not inside of it, beforeAll, afterAll, beforeEach or afterEach runs immediately on initialisation.
  • This means code at the end of your file runs before even your before hooks.
@tamlyn
tamlyn / .gitlab-ci.yml
Last active April 10, 2016 15:40
Dockerised Gitlab+Ci+Runner
before_script:
- npm install
test:
script: npm test