Skip to content

Commit

Permalink
Force prefers-reduced-motion on Chromium
Browse files Browse the repository at this point in the history
To prevent animations causing flakiness. I wish this worked for all browsers, but it doesn't.
  • Loading branch information
ahuth committed Sep 23, 2020
1 parent f93ab86 commit 1c9cf67
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ const options = Options.parse();

async function writeTests() {
// Get a browser page and navigate to Storybook's static iframe.
const browser = await playwright[options.browser].launch({ headless: options.headless });
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',
],
});
const context = await browser.newContext({ bypassCSP: true });
const page = await context.newPage();
await page.goto('file://' + options.iframePath);
Expand Down

0 comments on commit 1c9cf67

Please sign in to comment.