Exploring test setup and teardown
As tests can be quite long and contain a lot of repetitive actions, TestCafe has a way to optimize this with test setup and teardown.
Setup is usually done by executing a number of specific functions (also known as hooks) before a fixture or test starts (including fixture.before
, fixture.beforeEach
, and test.before
).
Teardown is usually done by executing a number of specific functions after a fixture or test is completed (including fixture.after
, fixture.afterEach
, and test.after
).
There are six methods for using hooks in TestCafe.
The first two (fixture.before
and fixture.after
) do not have access to the tested page and thus should be used to perform server-side operations, such as preparing the tested application's server or pre-creating some test data in the database:
fixture.before
can be used to specify actions that should be executed before the first test in a fixture starts (https://devexpress.github.io/testcafe/documentation...