// Check version of node to be 8
node -v //v4.1.1
// Move to node 8 using nvm
nvm use 8
node -v //v8.9.1
// Check testcafe is installed as global running
testcafe -v //~0.18.5
// If get "testcafe" command not found, install it global
npm install -g testcafe// Check available browsers
testcafe -b
// chrome
// firefox
// safari
// Running tests in Chrome
testcafe chrome test.js
// Running in all Browsers
testcafe all test.js
// Running in a remote browser
testcafe remote test.jsfixture(fixtureName) // Javascript
fixture `fixtureName` // Typescripttest(testName, function(t) {});
test(testName, async t => {});fixture('My Fixture').page('http://www.myexample.com');fixture('My Fixture').beforeEach(async t => {});fixture('My Fixture').afterEach(async t => {});test('My test', async t => {}).before(async t => {});test('My test', async t => {}).after(async t => {});test.page('http://www.myexample.com')('My Test', async t => {});fixture.skip
test.skip
fixture.only
test.onlyThe following example creates a selector from a css string for an element with 'username' id.
import { Selector } from 'testcafe';
const usernameInput = Selector('#username', {
visibilityCheck: true
});A test controller object t exposes methods of test API. That is why it is passed to each function that is expected to contain server-side test code (like test, beforeEach or afterEach).
Use the test controller to call test actions, handle browser dialogs, use the wait function or execute assertions.
await t.expect( actual ).eql( expected, message, options );
If the TestCafe assertion receives a Selector's DOM node state property or a client function promise as an actual value, TestCafe uses the smart assertion query mechanism: if an assertion did not pass, the test does not fail immediately. The assertion retries to pass multiple times and each time it requests the actual property value. The test fails if the assertion could not complete successfully within a timeout (default 3000ms)