Structuring the test code
To gain a better understanding of test code structure organization, let's divide it into several parts: fixtures, tests, the starting web page, metadata, and skipping tests.
Fixtures
TestCafe tests are usually grouped into test suites, called fixtures (which are the same as the describe
blocks in the Jasmine and Mocha test frameworks). Any JavaScript, TypeScript, or CoffeeScript files with TestCafe tests should contain one or more fixtures. Test fixtures can be declared with the fixture
function, which only accepts one argument—fixtureName
—which is a string for the name of the fixture (set of tests):
fixture('Name for the set of the tests');
Alternatively, you can write this without the brackets:
fixture `Name for the set of the tests`;
A fixture is basically a wrapper to indicate the beginning of a set of tests. Let's see how these tests should be structured.
Tests
Tests are usually written right after...