Skip to content

[Bug]: use.reducedMotion from config/test.use() is not applied to the runner-managed browser context #42001

Description

@buchalla-dev

Version

1.57.0

Steps to reproduce

  1. npm install @playwright/test@1.57.0
  2. playwright.config.ts:
import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: '.',
  use: {
    reducedMotion: 'reduce'
  }
});
  1. repro.spec.ts:
import { test, expect } from '@playwright/test';

test('use.reducedMotion from config is honored by the runner context', async ({ page }) => {
  await page.setContent('<p>hello</p>');
  const matches = await page.evaluate(() =>
    matchMedia('(prefers-reduced-motion: reduce)').matches
  );
  expect(matches).toBe(true);
});
  1. npx playwright test

Expected behavior

The test passes: matchMedia('(prefers-reduced-motion: reduce)') is true inside pages of the runner-managed browser context, because the config sets use.reducedMotion: 'reduce'.

Actual behavior

The test fails: matchMedia returns false. The option is silently not applied — neither from the config's top-level use nor from an explicit test.use({ reducedMotion: 'reduce' }) in the spec file.

Notably, a manually created context in the same test run honors the option:

test('probe', async ({ browser }) => {
  const ctx = await browser.newContext({ reducedMotion: 'reduce' });
  const page = await ctx.newPage();
  console.log(await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches)); // true
});

So the emulation itself works — the runner appears to drop reducedMotion when building the context for the page fixture. As a workaround, await page.emulateMedia({ reducedMotion: 'reduce' }) per page works.

Impact: tests relying on reduced-motion emulation (e.g. axe-core accessibility scans that must not run mid-animation) behave differently than the config suggests and become timing-flaky.

Additional context

  • Browser: chromium (default project, headless shell 143.0.7499.4)
  • Only tested with the default chromium project; no project-level use overrides involved (plain devices['Desktop Chrome'] does not change the outcome either).

Environment

System:
  OS: macOS 26.x (arm64, Apple Silicon)
  CPU: Apple M-series
Binaries:
  Node: 22.22.3
  npm/bun: bun 1.3.14
npmPackages:
  @playwright/test: 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