-
Notifications
You must be signed in to change notification settings - Fork 2
/
pa11yci.config.js
81 lines (72 loc) · 2.61 KB
/
pa11yci.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* Generate config for running Pa11yCI.
*
* Note, this config is also used as the source of URLs to test for Lighthouse CI.
*/
const getDeploymentTestUrls = require("./src/common-lib/urls/getDeploymentTestUrls");
const baseUrl = process.env.BASE_URL || "http://localhost:3000";
const isLocalHost = new URL(baseUrl).host === "localhost:3000";
// Cloudflare Access token
const CfAccessClientId = process.env.CF_ACCESS_CLIENT_ID;
const CfAccessClientSecret = process.env.CF_ACCESS_CLIENT_SECRET;
if (!isLocalHost && (!CfAccessClientId || !CfAccessClientSecret)) {
throw new TypeError(
"Please specify Cloudflare Access token headers in envs\nfor background info see https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/",
);
}
// https://github.com/pa11y/pa11y-ci#configuration
const config = {
defaults: {
userAgent: "oak testing Pa11y",
timeout: 120000,
runners: ["axe"],
hideElements:
/**
* Elements we hide from Pa11y.
*
* Metomic
* Avo
* Anything labelled with .pa11y-ignore (doesn't work if element has shadow-dom children for some reason)
*/
"#mtm-root-container, #mtm-frame-container, #avo-debugger, .pa11y-ignore",
ignore: [
// We have multiple instances of high-contrast text being detected as low-contrast
// because of low-contrast text shadows.
"color-contrast",
// Pa11y using Axe is looking for videos with track elements of type=captions, but the
// Mux player is rendering type=subtitles, so Pa11y is complaining, not sure who is wrong
"video-caption",
// There are also problems with the video controls being a <ul> with <slot> rather than <li> children.
// Eslint should prevent us doing this in components we control.
"list",
],
headers: {
"CF-Access-Client-Id": CfAccessClientId,
"CF-Access-Client-Secret": CfAccessClientSecret,
},
},
urls: [],
// log: {
// debug: console.log,
// error: console.error,
// info: console.info,
// },
};
const relativeUrls = getDeploymentTestUrls();
// Add the base URL to the relative URLs.
config.urls = relativeUrls.map((relUrl) => {
// This is the current default.
if (typeof relUrl === "string") {
const pa11yUrl = new URL(relUrl, baseUrl).href;
return {
url: pa11yUrl,
// Should help detect if we get served, e.g. a Cloudflare error page.
actions: ["wait for element #__next to be visible"],
};
// Return the already created URL config object.
} else {
relUrl.url = new URL(relUrl.url, baseUrl).href;
return relUrl;
}
});
module.exports = config;