Skip to content

Commit

Permalink
feat(acot-runner-storybook): add timeout options
Browse files Browse the repository at this point in the history
  • Loading branch information
wadackel committed Apr 18, 2021
1 parent e0dee85 commit 41b06f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/acot-runner-storybook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ The Story name pattern to exclude in the audit target. See the [micromatch][mm]
}
```

### `timeout`

**Type:** `number`
**Default:** `60000`
**Required:** `false`

Maximum time in milliseconds to wait for the browser instance to collect stories.

```json
{
"runner": {
"uses": "@acot/storybook",
"with": {
"timeout": 120000
}
}
}
```

## Storybook compatibility

### Storybook versions
Expand Down
9 changes: 9 additions & 0 deletions packages/acot-runner-storybook/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { AcotRunnerCollectResult } from '@acot/acot-runner';
import { AcotRunner } from '@acot/acot-runner';
const debug = require('debug')('acot:runner:storybook');

const DEFAULT_TIMEOUT = 60 * 1000;

type StoryParams = Omit<ConfigEntry, 'include' | 'exclude'>;

type Story = {
Expand Down Expand Up @@ -73,6 +75,7 @@ const filterStories = (
type Options = {
include?: string[];
exclude?: string[];
timeout?: number;
};

const schema: Schema = {
Expand All @@ -89,6 +92,10 @@ const schema: Schema = {
type: 'string',
},
},
timeout: {
type: 'number',
minimum: 0,
},
},
required: [],
additionalProperties: false,
Expand All @@ -100,6 +107,8 @@ export class StorybookRunner extends AcotRunner<Options> {
const browser = await puppeteer.launch(this.config.launchOptions);
const page = await browser.newPage();

page.setDefaultTimeout(this.options.timeout ?? DEFAULT_TIMEOUT);

let stories: AcotStory[] = [];

try {
Expand Down

0 comments on commit 41b06f9

Please sign in to comment.