Skip to content

Commit 30e2db8

Browse files
committed
Add option to override timeouts for larger scans
1 parent 7f8a65f commit 30e2db8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ If you've installed the plugin via `netlify.toml`, you can add a `[[plugins.inpu
100100
| `ignoreElements` | Indicates elements that should be ignored by a11y testing | String (CSS selector) | Comma-separated string of CSS selectors | `undefined` |
101101
| `ignoreGuidelines` | Indicates guidelines and types to ignore ([pa11y docs](https://github.com/pa11y/pa11y#ignore-array)) | Array of strings | Comma-separated string of WCAG Guidlines | `[]` |
102102
| `wcagLevel` | The WCAG standard level against which pages are checked | String | `'WCAG2A'` or `'WCAGA2A'` or `'WCAG2AAA'` | `'WCAG2AA'` |
103+
| `timeout` | Amount of time, in milliseconds, the scan will run before timing out. | Number | Any positive integer | 60000 |
103104

104105
Here's how these inputs can be used in `netlify.toml`, with comments to explain how each input affects the plugin's behavior:
105106

@@ -119,4 +120,6 @@ Here's how these inputs can be used in `netlify.toml`, with comments to explain
119120
ignoreGuidelines = ['WCAG2AA.Principle1.Guideline1_4.1_4_6.G17']
120121
# Perform a11y check against WCAG 2.1 AAA
121122
wcagLevel = 'WCAG2AAA'
123+
# Extends the timeout of the scan to 2 minutes (120000ms)
124+
timeout = 120000
122125
```

manifest.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ inputs:
1616
- name: wcagLevel
1717
default: 'WCAG2AA'
1818
description: The level of WCAG 2.1 against which to check site pages. Defaults to 'WCAGAA'; can also be 'WCAGA' or 'WCAGAAA'.
19+
- name: timeout
20+
default: 60000
21+
description: Amount of time, in milliseconds, the scan will run before timing out. Defaults to 60000.

src/config.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ type InputT = {
1010
ignoreGuidelines?: string[],
1111
failWithIssues?: boolean,
1212
wcagLevel?: WCAGLevel,
13+
timeout?: number,
1314
}
1415

1516
const DEFAULT_CHECK_PATHS = ['/']
1617
const DEFAULT_FAIL_WITH_ISSUES = true
1718
const DEFAULT_IGNORE_DIRECTORIES: string[] = []
19+
const DEFAULT_TIMEOUT: number = 60000
1820

1921
const PA11Y_DEFAULT_WCAG_LEVEL = 'WCAG2AA'
2022
const PA11Y_RUNNERS = ['axe']
@@ -24,7 +26,7 @@ export const getConfiguration = async ({
2426
constants: { PUBLISH_DIR },
2527
inputs,
2628
}: Pick<NetlifyPluginOptions, 'constants' | 'inputs'>) => {
27-
const { checkPaths, ignoreDirectories, ignoreElements, ignoreGuidelines, failWithIssues, wcagLevel } =
29+
const { checkPaths, ignoreDirectories, ignoreElements, ignoreGuidelines, failWithIssues, wcagLevel, timeout } =
2830
inputs as InputT
2931
return {
3032
checkPaths: checkPaths || DEFAULT_CHECK_PATHS,
@@ -34,21 +36,23 @@ export const getConfiguration = async ({
3436
hideElements: ignoreElements,
3537
ignore: ignoreGuidelines,
3638
standard: wcagLevel || PA11Y_DEFAULT_WCAG_LEVEL,
39+
timeout: timeout || DEFAULT_TIMEOUT,
3740
}),
3841
publishDir: (PUBLISH_DIR || process.env.PUBLISH_DIR) as string,
3942
}
4043
}
4144

4245
export type Config = ReturnType<typeof getConfiguration>
4346

44-
export const getPa11yOpts = async ({ hideElements, ignore, standard }: { hideElements?: string; ignore?: string[]; standard: WCAGLevel }) => {
47+
export const getPa11yOpts = async ({ hideElements, ignore, standard, timeout }: { hideElements?: string; ignore?: string[]; standard: WCAGLevel, timeout: number }) => {
4548
return {
4649
browser: await puppeteer.launch({ ignoreHTTPSErrors: true }),
4750
hideElements,
4851
ignore,
4952
runners: PA11Y_RUNNERS,
5053
userAgent: PA11Y_USER_AGENT,
5154
standard,
55+
timeout,
5256
}
5357
}
5458

0 commit comments

Comments
 (0)