test Function

Declares a test.

Note

Tests belong to fixtures — make sure you delclare a fixture before you declare a test!

test( testName, fn(t) ) → this
ParameterTypeDescription

testName

String

The name of the test.

fn

Function

An asynchronous function that contains test code.

t

Object

The test controller object (necessary to access test API).

fixture `My Fixture`;

test('Click a button', async t => {
    await t.click('#button');
});

test('Type something', async t => {
    await t.typeText('#comment', 'I love TestCafe')
});

You can also import the test object into your test file.

import { test } from 'testcafe';

fixture`Test import`
    .page('https://devexpress.github.io/testcafe/example');

test('Click a button', async t => {
    await t.click('#submit-button');
});