diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c66737..61426e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- [bugfix] Ensure `prefers-reduced-motion` is turned on [#33](https://github.com/chanzuckerberg/axe-storybook-testing/pull/33) + ## 4.0.0 (2021-09-13) - [breaking] Drop support for Node 10 [#29](https://github.com/chanzuckerberg/axe-storybook-testing/pull/29) diff --git a/src/browser/TestBrowser.ts b/src/browser/TestBrowser.ts index 6c17406..ab8aae1 100644 --- a/src/browser/TestBrowser.ts +++ b/src/browser/TestBrowser.ts @@ -16,12 +16,6 @@ export default class TestBrowser { static async create(options: Options): Promise { const browser = await playwright[options.browser].launch({ headless: options.headless, - args: [ - // Force the `prefers-reduced-motion` media query to be true in Chromium. This will prevent - // animations (that respect the media query) from causing flaky or failing tests due to the - // animation. Only works in Chromium, currently. - '--force-prefers-reduced-motion', - ], }); try { @@ -29,7 +23,15 @@ export default class TestBrowser { // Create a new page at Storybook's static iframe and with axe-core setup and ready to run. const page = await context.newPage(); + + // Turn on `prefers-reduced-motion`. This will prevent any animations that respect the media + // query from causing flaky or failing tests due to animation. + await page.emulateMedia({ reducedMotion: 'reduce' }); + + // Visit Storybook's static iframe. await page.goto(options.iframePath); + + // Ensure axe-core is setup and ready to run. await AxePage.prepare(page); return new TestBrowser(browser, page);