Fixture.beforeEach Method

Executes the code before each test in the fixture starts (the before each fixture hook).

fixture.beforeEach( fn(t) ) → this
Parameter Type Description
fn Function An asynchronous hook function that contains the hook code.
t Object The test controller used to access test run API.

If a test runs in several browsers, the hook is executed in each browser.

When the hook runs, the tested webpage is already loaded, and you can use test actions and other test run API inside the hook.


If test.before is specified, it overrides the corresponding fixture.beforeEach, and the latter is not executed.

fixture `My fixture`
    .page ``
    .beforeEach( async t => {
        await t

To specify code executed after each test in the fixture, use fixture.afterEach.