Skip to content

Commit

Permalink
change waitUntil param to take options
Browse files Browse the repository at this point in the history
changeset
  • Loading branch information
emiryy committed Aug 22, 2022
1 parent 9d07c6c commit 0d9702e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-dragons-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/storybook-a11y-test': minor
---

Allow waitUntil param to take options
9 changes: 6 additions & 3 deletions packages/storybook-a11y-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os from 'os';
import fs from 'fs';

import puppeteer, {Browser} from 'puppeteer';
import puppeteer, {Browser, PuppeteerLifeCycleEvent} from 'puppeteer';
import pMap from 'p-map';
import chalk from 'chalk';
import Koa from 'koa';
Expand Down Expand Up @@ -57,11 +57,13 @@ export class A11yTestRunner {
storyIds = [],
concurrentCount = os.cpus().length,
timeout = 3000,
waitUntil = 'load',
disableAnimation = false,
}: {
storyIds: StoryId[];
concurrentCount?: number;
timeout?: number;
waitUntil?: PuppeteerLifeCycleEvent;
disableAnimation?: boolean;
}) {
console.log(
Expand All @@ -75,7 +77,7 @@ export class A11yTestRunner {
console.log(chalk.bold(`🧪 Testing ${storyIds.length} urls with axe`));
const results = await pMap(
storyIds,
this.generateTestStoryFunction(timeout, disableAnimation),
this.generateTestStoryFunction(timeout, waitUntil, disableAnimation),
{
concurrency: concurrentCount,
},
Expand Down Expand Up @@ -146,6 +148,7 @@ export class A11yTestRunner {

private generateTestStoryFunction(
timeout: number,
waitUntil: PuppeteerLifeCycleEvent,
disableAnimation: boolean,
) {
return async (id: StoryId) => {
Expand All @@ -154,7 +157,7 @@ export class A11yTestRunner {

try {
await page.goto(`${this.iframePath}?id=${id}`, {
waitUntil: 'load',
waitUntil,
timeout,
});

Expand Down

0 comments on commit 0d9702e

Please sign in to comment.