Skip to content

[Feature]: Option to fail test on webServer stderr #38001

@karlhorky

Description

@karlhorky

🚀 Feature Request

Currently, if a webServer configuration emits stderr, it is only piped to the logs by default and the test execution continues.

In our test runs for our apps, we have encountered server exceptions which have been silently ignored for weeks, because the Playwright tests pass.

It would be useful to be able to configure webServer[number].stderr = 'fail' or a similar API, which would fail the currently running test if stderr is written to by the webServer process.

Possibly this should be also made the default value for webServer[number].stderr

Example

This configuration would result in test failure upon any stderr from either of the Frontend server or the Backend server:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  webServer: [
    {
      command: 'npm run start',
      url: 'http://localhost:3000',
      name: 'Frontend',
      timeout: 120 * 1000,
      reuseExistingServer: !process.env.CI,
+     stderr: 'fail',
    },
    {
      command: 'npm run backend',
      url: 'http://localhost:3333',
      name: 'Backend',
      timeout: 120 * 1000,
      reuseExistingServer: !process.env.CI,
+     stderr: 'fail',
    }
  ],
  use: {
    baseURL: 'http://localhost:3000',
  },
});

Motivation

Described in the first paragraphs of Feature Request

Alternatives Considered

  1. A wrapper script which can be used around all servers which crashes the process of stderr is emitted (downsides: increased complexity of test runner script and setup, possible unknown problems with Playwright test execution when crash occurs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions