Skip to content

Instantly share code, notes, and snippets.

@jimthedev
Created November 15, 2016 14:56
Show Gist options
  • Save jimthedev/41ce3bd7dfcb5ff8f744b6ad74f94d8a to your computer and use it in GitHub Desktop.
Save jimthedev/41ce3bd7dfcb5ff8f744b6ad74f94d8a to your computer and use it in GitHub Desktop.
Getting started with TestCafe Browser Testing

In Terminal, execute these to create an empty project:

  mkdir myproject
  cd myproject
  git init
  npm init --yes
  npm install -g testcafe
  npm install --save-dev chai

Create tests/fixtures/google.js with this content:

  import { expect } from 'chai';

  fixture `First test`
    .page(`http://google.com`)

    test('My Test', async t => {
        await t
            .typeText('input[name~="q"]', 'test cafe')
            .wait(1000);

        expect(await t.eval(() => document.querySelector('input[name~="q"]').value)).to.equal('test cafe');
    });

Run your test in Chrome with:

   testcafe chrome tests/fixtures/google.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment