Skip to content

[Bug]: Worker auto-fixture is nested into the first beforeAll hook #38690

@vitalets

Description

@vitalets

Version

1.57.0

Steps to reproduce

Full minimal reproduction code.

1. Create a test file with worker-scoped auto fixture and beforeAll hook:

import { test as base } from '@playwright/test';

const test = base.extend<{}, { workerFixture: void }>({
  workerFixture: [async ({}, use) => {
    await new Promise((r) => setTimeout(r, 1000)); // delay 1000 ms
    await use();
  }, { scope: 'worker', auto: true }]
})

test.beforeAll(async () => {
  await new Promise((r) => setTimeout(r, 100)); // delay 100 ms
});

test('test 1', async ({}) => { });

2. Run the test and check the result in the reporter API onTestEnd() method.

Expected behavior

  • worker fixture and beforeAll hook are placed on the same level in the result.steps array
  • beforeAll hook duration is ~100 ms
hook Before Hooks (1122ms)
  hook beforeAll hook (117ms)
  fixture Fixture "workerFixture" (1001ms)
hook After Hooks (3ms)

Actual behavior

  • worker fixture is nested under the beforeAll hook
  • beforeAll hook duration contains worker fixture duration, in total ~1100 ms instead of ~100 ms
hook Before Hooks (1139ms)
  hook beforeAll hook (1134ms)
    fixture Fixture "workerFixture" (1002ms)
hook After Hooks (4ms)

Additional context

  • If the worker fixture is not auto, the output structure is correct.
  • if there is another identical beforeAll hook, it does not contain the worker fixture, and it's duration is correct:
hook Before Hooks (1263ms)
  hook beforeAll hook (1131ms)
    fixture Fixture "workerFixture" (1004ms)
  hook beforeAll hook (121ms)
hook After Hooks (5ms)

Environment

System:
    OS: macOS 26.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 90.27 MB / 16.00 GB
  Binaries:
    Node: 20.18.3 - /Users/vitalets/.nvm/versions/node/v20.18.3/bin/node
    Yarn: 3.4.1 - /Users/vitalets/.nvm/versions/node/v20.18.3/bin/yarn
    npm: 11.6.0 - /Users/vitalets/.nvm/versions/node/v20.18.3/bin/npm
    pnpm: 9.15.4 - /Users/vitalets/.nvm/versions/node/v20.18.3/bin/pnpm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.57.0 => 1.57.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions