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 the 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.

import { utils } from './my-utils.js';

fixture `My fixture`
    .page `http://example.com`
    .before( async ctx => {
        utils.populateDb(ctx.dbName);
    });