Fixture.before Method

Executes code before the fixture starts (the before fixture hook).

fixture.before( fn(ctx) )
Parameter Type Description
fn Function An asynchronous hook function that contains the hook code.
ctx Object A fixture context object used to share variables between fixture hooks and test code.

Unlike test hooks, fixture hooks run between tests and do not have access to the tested page. Use them to perform server-side operations, like preparing the server that hosts the tested app.

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

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

To execute code after the fixture finishes, use the fixture.after method.