Skip to content

Commit 384ef88

Browse files
committed
Add option to override timeouts for larger scans
1 parent 73dedb1 commit 384ef88

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ package = "netlify-plugin-a11y"
4848

4949
# resultMode = "warn" # is "error" by default
5050

51+
# timeout = 60000 # in milliseconds; is 30000 by default
52+
5153
# # Developer only
5254
# debugMode = true # extra logging for plugin developers
5355
```

manifest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ inputs:
77
required: false
88
- name: resultMode
99
default: error
10+
- name: timeout
11+
default: 30000
1012
- name: debugMode
1113
default: false
1214
- name: testMode

plugin/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const pluginCore = require('./pluginCore');
99

1010
module.exports = {
1111
async onPostBuild({
12-
inputs: { checkPaths, ignoreDirectories, resultMode, debugMode },
12+
inputs: { checkPaths, ignoreDirectories, resultMode, timeout, debugMode },
1313
constants: { PUBLISH_DIR },
1414
utils: { build }
1515
}) {
@@ -24,6 +24,7 @@ module.exports = {
2424
const results = await pluginCore.runPa11y({
2525
htmlFilePaths,
2626
build,
27+
timeout,
2728
debugMode
2829
});
2930

plugin/pluginCore.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const pa11y = require('pa11y');
44
const readdirp = require('readdirp')
55
const { isDirectory, isFile } = require('path-type')
66

7-
exports.runPa11y = async function({ htmlFilePaths, build, testMode, debugMode }) {
8-
let results = await Promise.all(htmlFilePaths.map(htmlFilePath => runPa11yOnFile(htmlFilePath, build)));
7+
exports.runPa11y = async function({ htmlFilePaths, build, timeout, testMode, debugMode }) {
8+
let results = await Promise.all(htmlFilePaths.map(htmlFilePath => runPa11yOnFile(htmlFilePath, build, timeout)));
99
results = results
1010
.filter((res) => res.issues.length)
1111
.map((res) =>
@@ -25,9 +25,9 @@ exports.runPa11y = async function({ htmlFilePaths, build, testMode, debugMode })
2525
return flattenedResults;
2626
};
2727

28-
const runPa11yOnFile = async function(htmlFilePath, build) {
28+
const runPa11yOnFile = async function(htmlFilePath, build, timeout) {
2929
try {
30-
return await pa11y(htmlFilePath)
30+
return await pa11y(htmlFilePath, {timeout, chromeLaunchConfig: {timeout}})
3131
} catch (error) {
3232
build.failBuild(`pa11y failed`, { error })
3333
}

tests/runPa11y/this.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const pluginCore = require('../../plugin/pluginCore.js');
66
test('runPa11y works', async () => {
77
const results = await pluginCore.runPa11y({
88
htmlFilePaths: [path.join(__dirname, 'publishDir/index.html')],
9-
build: { failBuild() {} }
9+
build: { failBuild() {} },
10+
timeout: 30000
1011
});
1112
expect(results).toMatchSnapshot();
1213
});

0 commit comments

Comments
 (0)