Skip to content

[Feature]: [Reporter API] Report "Worker Cleanup" data in successful run #38350

@vitalets

Description

@vitalets

🚀 Feature Request

Currently, the ‘Worker Cleanup’ data is only reported for failing tests. It would be useful to have it available for successful runs as well.

Example

Given a test and a worker-scope fixture whose teardown takes 1 second:

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

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

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

});

In my custom reporter, I want to detect this 1s delay as part of the workerFixture teardown so I can help users identify and optimize heavy worker-scope cleanup.

However, when running the test successfully, this teardown time does not appear anywhere in the onTestEnd callback.

Here is the simplified, indented output of the result object:

test 1 (1ms)
  hook Before Hooks (6ms)
    fixture Fixture "workerFixture" (0ms)
  hook After Hooks (6ms)

But if I modify the test to throw an error:

test('test 1', async ({ workerFixture }) => {
  throw new Error('error');
});

Then the result steps include a Worker Cleanup hook showing the worker fixture teardown duration:

test 1 (3ms)
  hook Before Hooks (7ms)
    fixture Fixture "workerFixture" (0ms)
  hook After Hooks (5ms)
  hook Worker Cleanup (1002ms)
    fixture Fixture "workerFixture" (1002ms)

Motivation

Having Worker Cleanup data in successful test runs would make it much easier for custom reporters to help users identify optimization points.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions