Fixture.before Method

Defines the before fixture hook. The before fixture hook runs before the beginning of the first test in the fixture.

fixture.before( fn(ctx) ) → this
Parameter Type Description
fn Function An asynchronous hook function that contains hook code.
ctx Object A fixture context object that stores user-defined data.

Fixture hooks run between tests and, as such, cannot access the browser. Use them to perform server-side operations. To perform browser operations before and after tests, use test hooks.

Use the fixture.after hook to execute code after the final fixture test.

fixture`Fixture.before`
    .page`https://devexpress.github.io/testcafe/example/`
    .before(async ctx => {
        ctx.db = { name: 'test' };
    });