@axe-core/cli 4.7.4-alpha.408 → 4.7.4-f03670b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +11 -45
  2. package/package.json +8 -11
  3. package/src/bin/cli.test.ts +14 -1
  4. package/src/bin/cli.ts +4 -0
  5. package/src/bin/index.ts +35 -3
  6. package/src/lib/utils.test.ts +45 -15
  7. package/src/lib/utils.ts +21 -17
  8. package/src/lib/webdriver.ts +5 -0
  9. package/src/testutils/axe-core@2.5.0.js +54 -66
  10. package/src/types.ts +1 -0
  11. package/dist/package.json +0 -91
  12. package/dist/src/bin/cli.d.ts +0 -2
  13. package/dist/src/bin/cli.js +0 -39
  14. package/dist/src/bin/cli.js.map +0 -1
  15. package/dist/src/bin/cli.test.d.ts +0 -1
  16. package/dist/src/bin/cli.test.js +0 -251
  17. package/dist/src/bin/cli.test.js.map +0 -1
  18. package/dist/src/bin/index.d.ts +0 -5
  19. package/dist/src/bin/index.js +0 -138
  20. package/dist/src/bin/index.js.map +0 -1
  21. package/dist/src/lib/axe-test-urls.d.ts +0 -4
  22. package/dist/src/lib/axe-test-urls.js +0 -89
  23. package/dist/src/lib/axe-test-urls.js.map +0 -1
  24. package/dist/src/lib/axe-test-urls.test.d.ts +0 -1
  25. package/dist/src/lib/axe-test-urls.test.js +0 -73
  26. package/dist/src/lib/axe-test-urls.test.js.map +0 -1
  27. package/dist/src/lib/events.d.ts +0 -10
  28. package/dist/src/lib/events.js +0 -54
  29. package/dist/src/lib/events.js.map +0 -1
  30. package/dist/src/lib/events.test.d.ts +0 -1
  31. package/dist/src/lib/events.test.js +0 -31
  32. package/dist/src/lib/events.test.js.map +0 -1
  33. package/dist/src/lib/index.d.ts +0 -4
  34. package/dist/src/lib/index.js +0 -36
  35. package/dist/src/lib/index.js.map +0 -1
  36. package/dist/src/lib/utils.d.ts +0 -15
  37. package/dist/src/lib/utils.js +0 -120
  38. package/dist/src/lib/utils.js.map +0 -1
  39. package/dist/src/lib/utils.test.d.ts +0 -1
  40. package/dist/src/lib/utils.test.js +0 -140
  41. package/dist/src/lib/utils.test.js.map +0 -1
  42. package/dist/src/lib/webdriver.d.ts +0 -4
  43. package/dist/src/lib/webdriver.js +0 -46
  44. package/dist/src/lib/webdriver.js.map +0 -1
  45. package/dist/src/lib/webdriver.test.d.ts +0 -1
  46. package/dist/src/lib/webdriver.test.js +0 -102
  47. package/dist/src/lib/webdriver.test.js.map +0 -1
  48. package/dist/src/testutils/index.d.ts +0 -19
  49. package/dist/src/testutils/index.js +0 -51
  50. package/dist/src/testutils/index.js.map +0 -1
  51. package/dist/src/types.d.ts +0 -36
  52. package/dist/src/types.js +0 -18
  53. package/dist/src/types.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,82 +7,48 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
7
7
 
8
8
  **Note:** Version bump only for package @axe-core/cli
9
9
 
10
-
11
-
12
-
13
-
14
10
  ## [4.7.2](https://github.com/dequelabs/axe-core-npm/compare/v4.7.1...v4.7.2) (2023-06-01)
15
11
 
16
-
17
12
  ### Bug Fixes
18
13
 
19
- * **packages/cli:** revert ESM ([#730](https://github.com/dequelabs/axe-core-npm/issues/730)) ([4e1fb95](https://github.com/dequelabs/axe-core-npm/commit/4e1fb958fa251db7eea3433f91f2a2f3adbda1e8))
20
-
21
-
22
-
23
-
14
+ - **packages/cli:** revert ESM ([#730](https://github.com/dequelabs/axe-core-npm/issues/730)) ([4e1fb95](https://github.com/dequelabs/axe-core-npm/commit/4e1fb958fa251db7eea3433f91f2a2f3adbda1e8))
24
15
 
25
16
  ## [4.7.1](https://github.com/dequelabs/axe-core-npm/compare/v4.7.0...v4.7.1) (2023-05-02)
26
17
 
27
18
  **Note:** Version bump only for package @axe-core/cli
28
19
 
29
-
30
-
31
-
32
-
33
20
  # [4.7.0](https://github.com/dequelabs/axe-core-npm/compare/v4.6.1...v4.7.0) (2023-04-28)
34
21
 
35
-
36
22
  ### Bug Fixes
37
23
 
38
- * **cli:** do not inject script tags due to pages not allowing script tags ([#710](https://github.com/dequelabs/axe-core-npm/issues/710)) ([2e0fdb4](https://github.com/dequelabs/axe-core-npm/commit/2e0fdb4a4661040b9b8dbb91bed1a96142e4fe0c))
39
-
24
+ - **cli:** do not inject script tags due to pages not allowing script tags ([#710](https://github.com/dequelabs/axe-core-npm/issues/710)) ([2e0fdb4](https://github.com/dequelabs/axe-core-npm/commit/2e0fdb4a4661040b9b8dbb91bed1a96142e4fe0c))
40
25
 
41
26
  ### Features
42
27
 
43
- * enable esm import ([#713](https://github.com/dequelabs/axe-core-npm/issues/713)) ([076bfa9](https://github.com/dequelabs/axe-core-npm/commit/076bfa99f27f416b4eaff6d24cc23e8573fc72ee))
44
- * Update axe-core to v4.7.0 ([#709](https://github.com/dequelabs/axe-core-npm/issues/709)) ([d418d09](https://github.com/dequelabs/axe-core-npm/commit/d418d093b4c462d5d60e0f7ad3d5147bcaf52aa2))
45
-
46
-
47
-
48
-
28
+ - enable esm import ([#713](https://github.com/dequelabs/axe-core-npm/issues/713)) ([076bfa9](https://github.com/dequelabs/axe-core-npm/commit/076bfa99f27f416b4eaff6d24cc23e8573fc72ee))
29
+ - Update axe-core to v4.7.0 ([#709](https://github.com/dequelabs/axe-core-npm/issues/709)) ([d418d09](https://github.com/dequelabs/axe-core-npm/commit/d418d093b4c462d5d60e0f7ad3d5147bcaf52aa2))
49
30
 
50
31
  ## [4.6.1](https://github.com/dequelabs/axe-core-npm/compare/v4.6.0...v4.6.1) (2023-03-28)
51
32
 
52
-
53
33
  ### Bug Fixes
54
34
 
55
- * **cli:** increase --timeout default to 90 seconds (to match --help) ([#683](https://github.com/dequelabs/axe-core-npm/issues/683)) ([d11481b](https://github.com/dequelabs/axe-core-npm/commit/d11481b8c74598617260586fe14c8ceba32c6792))
56
- * Update axe-core to v4.6.3 ([#698](https://github.com/dequelabs/axe-core-npm/issues/698)) ([a7d53a4](https://github.com/dequelabs/axe-core-npm/commit/a7d53a4876237c74bb8dc2836b703cdaf2f7ace5))
57
-
58
-
59
-
60
-
35
+ - **cli:** increase --timeout default to 90 seconds (to match --help) ([#683](https://github.com/dequelabs/axe-core-npm/issues/683)) ([d11481b](https://github.com/dequelabs/axe-core-npm/commit/d11481b8c74598617260586fe14c8ceba32c6792))
36
+ - Update axe-core to v4.6.3 ([#698](https://github.com/dequelabs/axe-core-npm/issues/698)) ([a7d53a4](https://github.com/dequelabs/axe-core-npm/commit/a7d53a4876237c74bb8dc2836b703cdaf2f7ace5))
61
37
 
62
38
  # [4.6.0](https://github.com/dequelabs/axe-core-npm/compare/v4.5.2...v4.6.0) (2023-01-19)
63
39
 
64
-
65
40
  ### Features
66
41
 
67
- * support shadow dom selectors ([#619](https://github.com/dequelabs/axe-core-npm/issues/619)) ([6065b56](https://github.com/dequelabs/axe-core-npm/commit/6065b562adf289341033a7233426ba3dcfb8a24b))
68
- * Update axe-core to v4.6.1 ([#633](https://github.com/dequelabs/axe-core-npm/issues/633)) ([8bab5b2](https://github.com/dequelabs/axe-core-npm/commit/8bab5b23b3653a6a0603f10d889e22418a4fff3e))
69
-
70
-
71
-
72
-
42
+ - support shadow dom selectors ([#619](https://github.com/dequelabs/axe-core-npm/issues/619)) ([6065b56](https://github.com/dequelabs/axe-core-npm/commit/6065b562adf289341033a7233426ba3dcfb8a24b))
43
+ - Update axe-core to v4.6.1 ([#633](https://github.com/dequelabs/axe-core-npm/issues/633)) ([8bab5b2](https://github.com/dequelabs/axe-core-npm/commit/8bab5b23b3653a6a0603f10d889e22418a4fff3e))
73
44
 
74
45
  ## [4.5.2](https://github.com/dequelabs/axe-core-npm/compare/v4.5.1...v4.5.2) (2022-11-15)
75
46
 
76
-
77
47
  ### Bug Fixes
78
48
 
79
- * **cli:** include all functions in types file ([#603](https://github.com/dequelabs/axe-core-npm/issues/603)) ([30042ef](https://github.com/dequelabs/axe-core-npm/commit/30042ef3acc0cab7f67ddcf284df089f243f53e6))
80
- * **cli:** use correct driver typings ([#604](https://github.com/dequelabs/axe-core-npm/issues/604)) ([d33bbdf](https://github.com/dequelabs/axe-core-npm/commit/d33bbdf2b3d05c3ba0106d717ba1c8d706c5e05c))
81
- * update to use axe-core 4.5.2 ([#607](https://github.com/dequelabs/axe-core-npm/issues/607)) ([61312ff](https://github.com/dequelabs/axe-core-npm/commit/61312fff2e9ee4e0f218a29a1608f69b45206fad))
82
-
83
-
84
-
85
-
49
+ - **cli:** include all functions in types file ([#603](https://github.com/dequelabs/axe-core-npm/issues/603)) ([30042ef](https://github.com/dequelabs/axe-core-npm/commit/30042ef3acc0cab7f67ddcf284df089f243f53e6))
50
+ - **cli:** use correct driver typings ([#604](https://github.com/dequelabs/axe-core-npm/issues/604)) ([d33bbdf](https://github.com/dequelabs/axe-core-npm/commit/d33bbdf2b3d05c3ba0106d717ba1c8d706c5e05c))
51
+ - update to use axe-core 4.5.2 ([#607](https://github.com/dequelabs/axe-core-npm/issues/607)) ([61312ff](https://github.com/dequelabs/axe-core-npm/commit/61312fff2e9ee4e0f218a29a1608f69b45206fad))
86
52
 
87
53
  ## [4.5.1](https://github.com/dequelabs/axe-core-npm/compare/v4.5.0...v4.5.1) (2022-11-03)
88
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axe-core/cli",
3
- "version": "4.7.4-alpha.408+502b6c2",
3
+ "version": "4.7.4-f03670b.0+f03670b",
4
4
  "description": "A CLI for accessibility testing using axe-core",
5
5
  "author": {
6
6
  "name": "Wilco Fiers",
@@ -32,8 +32,7 @@
32
32
  "prebuild": "rimraf dist",
33
33
  "build": "tsc",
34
34
  "test": "mocha --timeout 60000 -r ts-node/register 'src/**/**.test.ts'",
35
- "coverage": "nyc npm run test",
36
- "prepare": "npm run build"
35
+ "coverage": "nyc npm run test"
37
36
  },
38
37
  "keywords": [
39
38
  "axe-core",
@@ -44,9 +43,9 @@
44
43
  "testing"
45
44
  ],
46
45
  "dependencies": {
47
- "@axe-core/webdriverjs": "4.7.4-alpha.408+502b6c2",
48
- "axe-core": "^4.7.0",
49
- "chromedriver": "^113.0.0",
46
+ "@axe-core/webdriverjs": "4.7.4-f03670b.0+f03670b",
47
+ "axe-core": "~4.8.2",
48
+ "chromedriver": "latest",
50
49
  "colors": "^1.4.0",
51
50
  "commander": "^9.4.1",
52
51
  "selenium-webdriver": "^4.8.1"
@@ -55,15 +54,13 @@
55
54
  "@types/chai": "^4.3.3",
56
55
  "@types/chromedriver": "^81.0.1",
57
56
  "@types/mocha": "^10.0.0",
58
- "@types/mock-fs": "^4.13.1",
59
57
  "@types/selenium-webdriver": "^4.1.5",
60
58
  "chai": "^4.3.6",
61
59
  "execa": "5.1.0",
62
60
  "mocha": "^10.0.0",
63
- "mock-fs": "^5.1.4",
64
61
  "nyc": "^15.1.0",
65
62
  "rimraf": "^3.0.2",
66
- "tempy": "1.0.0",
63
+ "tempy": "^1.0.0",
67
64
  "ts-node": "^10.9.1",
68
65
  "typescript": "^4.8.4"
69
66
  },
@@ -77,7 +74,7 @@
77
74
  "html"
78
75
  ],
79
76
  "statements": 95,
80
- "branches": 92,
77
+ "branches": 91,
81
78
  "functions": 94,
82
79
  "lines": 95,
83
80
  "exclude": [
@@ -87,5 +84,5 @@
87
84
  "src/testutils"
88
85
  ]
89
86
  },
90
- "gitHead": "502b6c2954bee68bb483bfcf58af9b34471f06d0"
87
+ "gitHead": "f03670beb2c3f46c698a3d607de6bdae7565d79d"
91
88
  }
@@ -391,7 +391,9 @@ describe('cli', () => {
391
391
  });
392
392
  });
393
393
 
394
- describe('--chromedriver-path', () => {
394
+ // disabled during conversion to npm workspaces as the node_module install directory changed
395
+ // @see https://github.com/dequelabs/axe-core-npm/issues/822
396
+ describe.skip('--chromedriver-path', () => {
395
397
  it('should throw error if path does not exist', async () => {
396
398
  const result = await runCLI(
397
399
  `file://${SIMPLE_HTML_FILE}`,
@@ -404,4 +406,15 @@ describe('cli', () => {
404
406
  );
405
407
  });
406
408
  });
409
+
410
+ describe('--chrome-path', () => {
411
+ it('should throw error if path does not exist', async () => {
412
+ const result = await runCLI(
413
+ `file://${SIMPLE_HTML_FILE}`,
414
+ '--chrome-path="someinvalidpath"',
415
+ '--show-errors'
416
+ );
417
+ assert.include(result.stderr, 'no chrome binary at');
418
+ });
419
+ });
407
420
  });
package/src/bin/cli.ts CHANGED
@@ -77,6 +77,10 @@ program
77
77
  '--chromedriver-path <path>',
78
78
  'Absolute path to the desired chromedriver executable'
79
79
  )
80
+ .option(
81
+ '--chrome-path <path>',
82
+ 'Path to the desired chrome executable'
83
+ )
80
84
  .action(cli);
81
85
 
82
86
  program.parse(process.argv);
package/src/bin/index.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  import axeTestUrls from '../lib/axe-test-urls';
16
16
  import event from '../lib/events';
17
17
  import { startDriver } from '../lib/webdriver';
18
+ import { error as selenium_error } from 'selenium-webdriver';
18
19
 
19
20
  const cli = async (
20
21
  args: OptionValues,
@@ -36,7 +37,8 @@ const cli = async (
36
37
  rules,
37
38
  disable,
38
39
  loadDelay,
39
- chromedriverPath
40
+ chromedriverPath,
41
+ chromePath
40
42
  } = args;
41
43
 
42
44
  const showErrors = args.showErrors === true;
@@ -67,7 +69,8 @@ const cli = async (
67
69
  browser: args.browser,
68
70
  timeout,
69
71
  chromeOptions,
70
- chromedriverPath
72
+ chromedriverPath,
73
+ chromePath
71
74
  };
72
75
 
73
76
  args.driver = startDriver(driverConfigs);
@@ -106,8 +109,37 @@ const cli = async (
106
109
  rules,
107
110
  disable
108
111
  };
112
+ let outcome;
109
113
  try {
110
- const outcome = await axeTestUrls(urls, testPageConfigParams, events);
114
+ try {
115
+ outcome = await axeTestUrls(urls, testPageConfigParams, events);
116
+ } catch (e) {
117
+ if (e instanceof selenium_error.ScriptTimeoutError) {
118
+ console.error(error('Error: %s'), e.message);
119
+ console.log(`The timeout is currently configured to be ${timeout} seconds (you can change it with --timeout).`)
120
+ process.exit(2);
121
+ }
122
+ // Provide a more user-friendly error message when there's a ChromeDriver/Chrome version mismatch.
123
+ else if (
124
+ e instanceof selenium_error.SessionNotCreatedError &&
125
+ e.message.includes(
126
+ 'This version of ChromeDriver only supports'
127
+ // This string has to match the error message printed by chromedriver, see
128
+ // https://chromium.googlesource.com/chromium/src/+/refs/tags/110.0.5481.194/chrome/test/chromedriver/chrome_launcher.cc#300.
129
+ )
130
+ ) {
131
+ console.error(error('Error: %s'), e.message);
132
+ console.log(`\nPlease install a matching version of ChromeDriver and run axe with the --chromedriver-path option:
133
+
134
+ $ npm install -g chromedriver@<version>
135
+ $ axe --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver <url...>
136
+
137
+ (where <version> is the first number of the "current browser version" reported above.)`);
138
+ process.exit(2);
139
+ } else {
140
+ throw e;
141
+ }
142
+ }
111
143
  if (silentMode) {
112
144
  process.stdout.write(JSON.stringify(outcome, null, 2));
113
145
  return;
@@ -1,6 +1,8 @@
1
1
  import 'mocha';
2
2
  import { assert } from 'chai';
3
- import mock = require('mock-fs');
3
+ import tempy from 'tempy';
4
+ import { join } from 'path';
5
+ import { mkdirSync, writeFileSync, rmSync } from 'fs';
4
6
  import { dependencies } from '../../package.json';
5
7
  import * as utils from './utils';
6
8
 
@@ -74,24 +76,52 @@ describe('utils', () => {
74
76
 
75
77
  describe('getAxeSource', () => {
76
78
  describe('mock file', () => {
77
- beforeEach(() => {
78
- mock({
79
- '/node_modules/axe-core': {},
80
- '../node_modules/axe-core': {
81
- 'axe.js': mock.load(require.resolve('axe-core'))
82
- }
83
- });
84
- });
79
+ function setupTree() {
80
+ const tempDir = tempy.directory();
81
+ const parentDirname = join(tempDir, 'node_modules', 'axe-core');
82
+ mkdirSync(parentDirname, { recursive: true });
83
+ writeFileSync(join(parentDirname, 'axe.js'), 'parent');
84
+
85
+ const cliDirname = join(tempDir, 'packages', 'cli');
86
+ const nodeModDirname = join(
87
+ cliDirname,
88
+ 'node_modules',
89
+ 'axe-core'
90
+ );
91
+ mkdirSync(nodeModDirname, { recursive: true });
92
+ writeFileSync(join(nodeModDirname, 'axe.js'), 'node modules');
93
+
94
+ const cwdDirname = join(tempDir, 'packages', 'cli', 'lib');
95
+ mkdirSync(cwdDirname);
96
+ writeFileSync(join(cwdDirname, 'axe.js'), 'cwd');
97
+ return {
98
+ cliDirname,
99
+ parentDirname,
100
+ nodeModDirname,
101
+ cwdDirname
102
+ };
103
+ }
85
104
 
86
- afterEach(() => {
87
- mock.restore();
105
+ it('uses axe.js from the working directory if it exists', () => {
106
+ const { cwdDirname } = setupTree();
107
+ const axeSource = utils.getAxeSource(undefined, cwdDirname);
108
+ assert.include(axeSource, 'cwd');
88
109
  });
89
- it('fall back to use `locally` installed axe-core', () => {
90
- const axeSource = utils.getAxeSource();
91
- const axeVersionCheck = dependencies['axe-core'].replace('^', '');
92
- assert.include(axeSource, axeVersionCheck);
110
+ it("falls back to axe-core from the working directory's node_modules if axe.js doesn't exist in the working directory", () => {
111
+ const { cliDirname, cwdDirname } = setupTree();
112
+ rmSync(join(cwdDirname, 'axe.js'));
113
+ const axeSource = utils.getAxeSource(undefined, cliDirname);
114
+ assert.include(axeSource, 'node modules');
115
+ });
116
+ it("falls back to axe-core from our own package's node_modules if no working-directory based implementation exists", () => {
117
+ const { cwdDirname, nodeModDirname } = setupTree();
118
+ rmSync(join(cwdDirname, 'axe.js'));
119
+ rmSync(join(nodeModDirname, 'axe.js'));
120
+ const axeSource = utils.getAxeSource(undefined, cwdDirname);
121
+ assert.include(axeSource, 'parent');
93
122
  });
94
123
  });
124
+
95
125
  it('given no axe source use local source', () => {
96
126
  const axeSource = utils.getAxeSource();
97
127
  assert.isNotNull(axeSource);
package/src/lib/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import colors from 'colors';
4
- import { AxeResults } from 'axe-core';
4
+ import type { AxeResults, UnlabelledFrameSelector } from 'axe-core';
5
5
 
6
6
  export const saveOutcome = (
7
7
  outcome: AxeResults | AxeResults[],
@@ -70,35 +70,39 @@ export const parseBrowser = (browser?: string): string | Error => {
70
70
  }
71
71
  };
72
72
 
73
- export const getAxeSource = (axePath?: string): string | void => {
73
+ export const getAxeSource = (
74
+ axePath?: string,
75
+ dirname?: string
76
+ ): string | void => {
74
77
  // Abort if axePath should exist, and it isn't
75
78
  if (axePath && !fs.existsSync(axePath)) {
76
79
  return;
77
80
  }
78
81
 
82
+ let cwd = dirname;
83
+ if (!cwd) {
84
+ cwd = process.cwd();
85
+ }
86
+
87
+ if (!dirname) {
88
+ dirname = __dirname;
89
+ }
90
+
79
91
  // Look for axe in current working directory
80
92
  if (!axePath) {
81
- axePath = path.join(process.cwd(), 'axe.js');
93
+ axePath = path.join(cwd, 'axe.js');
82
94
  }
83
95
 
84
96
  if (!fs.existsSync(axePath)) {
85
97
  // Look for axe in CWD ./node_modules
86
- axePath = path.join(process.cwd(), 'node_modules', 'axe-core', 'axe.js');
98
+ axePath = path.join(cwd, 'node_modules', 'axe-core', 'axe.js');
87
99
  }
88
100
 
89
101
  if (!fs.existsSync(axePath)) {
90
- // `__dirname` is /@axe-core/cli/dist/src/lib when installed globally
91
- // to access the locally installed axe-core package we need to go up 3 levels
92
- // if all else fails, use the locally installed axe
93
- axePath = path.join(
94
- __dirname,
95
- '..',
96
- '..',
97
- '..',
98
- 'node_modules',
99
- 'axe-core',
100
- 'axe.js'
101
- );
102
+ // in local develop using npm workspaces axe-core is
103
+ // hoisted to the root, but when published axe-core
104
+ // will be in the node_modules for the cli
105
+ axePath = require.resolve('axe-core/axe.js');
102
106
  }
103
107
 
104
108
  return fs.readFileSync(axePath, 'utf-8');
@@ -114,7 +118,7 @@ export const splitList = (val: string): string[] => {
114
118
  };
115
119
 
116
120
  export const selectorToString = (
117
- selectors: string[],
121
+ selectors: UnlabelledFrameSelector,
118
122
  separator?: string
119
123
  ): string => {
120
124
  separator = separator || ' ';
@@ -1,3 +1,4 @@
1
+ import path from 'path';
1
2
  import chromedriver from 'chromedriver';
2
3
  import { Builder, type WebDriver } from 'selenium-webdriver';
3
4
  import chrome from 'selenium-webdriver/chrome';
@@ -21,6 +22,10 @@ const startDriver = async (
21
22
  }, options);
22
23
  }
23
24
 
25
+ if (config.chromePath) {
26
+ options.setChromeBinaryPath(path.resolve(config.chromePath));
27
+ }
28
+
24
29
  builder = new Builder()
25
30
  .forBrowser('chrome')
26
31
  .setChromeOptions(options)
@@ -1096,15 +1096,14 @@
1096
1096
  }
1097
1097
  axe._load = function (audit) {
1098
1098
  'use strict';
1099
- axe.utils.respondable.subscribe('axe.ping', function (
1100
- data,
1101
- keepalive,
1102
- respond
1103
- ) {
1104
- respond({
1105
- axe: true
1106
- });
1107
- });
1099
+ axe.utils.respondable.subscribe(
1100
+ 'axe.ping',
1101
+ function (data, keepalive, respond) {
1102
+ respond({
1103
+ axe: true
1104
+ });
1105
+ }
1106
+ );
1108
1107
  axe.utils.respondable.subscribe('axe.start', runCommand);
1109
1108
  axe._audit = new Audit(audit);
1110
1109
  };
@@ -1843,16 +1842,20 @@
1843
1842
  timeout = setTimeout(function () {
1844
1843
  reject(err('Axe in frame timed out', node));
1845
1844
  }, 3e4);
1846
- axe.utils.respondable(win, 'axe.start', parameters, undefined, function (
1847
- data
1848
- ) {
1849
- clearTimeout(timeout);
1850
- if (data instanceof Error === false) {
1851
- resolve(data);
1852
- } else {
1853
- reject(data);
1845
+ axe.utils.respondable(
1846
+ win,
1847
+ 'axe.start',
1848
+ parameters,
1849
+ undefined,
1850
+ function (data) {
1851
+ clearTimeout(timeout);
1852
+ if (data instanceof Error === false) {
1853
+ resolve(data);
1854
+ } else {
1855
+ reject(data);
1856
+ }
1854
1857
  }
1855
- });
1858
+ );
1856
1859
  });
1857
1860
  };
1858
1861
  function collectResultsFromFrames(
@@ -3779,8 +3782,7 @@
3779
3782
  checkboxgroup: {
3780
3783
  description:
3781
3784
  'Ensures related <input type="checkbox"> elements have a group and that that group designation is consistent',
3782
- help:
3783
- 'Checkbox inputs with the same name attribute value must be part of a group'
3785
+ help: 'Checkbox inputs with the same name attribute value must be part of a group'
3784
3786
  },
3785
3787
  'color-contrast': {
3786
3788
  description:
@@ -3789,8 +3791,7 @@
3789
3791
  },
3790
3792
  'definition-list': {
3791
3793
  description: 'Ensures <dl> elements are structured correctly',
3792
- help:
3793
- '<dl> elements must only directly contain properly-ordered <dt> and <dd> groups, <script> or <template> elements'
3794
+ help: '<dl> elements must only directly contain properly-ordered <dt> and <dd> groups, <script> or <template> elements'
3794
3795
  },
3795
3796
  dlitem: {
3796
3797
  description: 'Ensures <dt> and <dd> elements are contained by a <dl>',
@@ -3830,8 +3831,7 @@
3830
3831
  'href-no-hash': {
3831
3832
  description:
3832
3833
  'Ensures that href values are valid link references to promote only using anchors as links',
3833
- help:
3834
- 'Anchors must only be used as links with valid URLs or URL fragments'
3834
+ help: 'Anchors must only be used as links with valid URLs or URL fragments'
3835
3835
  },
3836
3836
  'html-has-lang': {
3837
3837
  description: 'Ensures every HTML document has a lang attribute',
@@ -3850,8 +3850,7 @@
3850
3850
  'image-redundant-alt': {
3851
3851
  description:
3852
3852
  'Ensure button and link text is not repeated as image alternative',
3853
- help:
3854
- 'Text of buttons and links should not be repeated in the image alternative'
3853
+ help: 'Text of buttons and links should not be repeated in the image alternative'
3855
3854
  },
3856
3855
  'input-image-alt': {
3857
3856
  description:
@@ -3874,8 +3873,7 @@
3874
3873
  },
3875
3874
  'link-in-text-block': {
3876
3875
  description: 'Links can be distinguished without relying on color',
3877
- help:
3878
- 'Links must be distinguished from surrounding text in a way that does not rely on color'
3876
+ help: 'Links must be distinguished from surrounding text in a way that does not rely on color'
3879
3877
  },
3880
3878
  'link-name': {
3881
3879
  description: 'Ensures links have discernible text',
@@ -3883,8 +3881,7 @@
3883
3881
  },
3884
3882
  list: {
3885
3883
  description: 'Ensures that lists are structured correctly',
3886
- help:
3887
- '<ul> and <ol> must only directly contain <li>, <script> or <template> elements'
3884
+ help: '<ul> and <ol> must only directly contain <li>, <script> or <template> elements'
3888
3885
  },
3889
3886
  listitem: {
3890
3887
  description: 'Ensures <li> elements are used semantically',
@@ -3914,14 +3911,12 @@
3914
3911
  },
3915
3912
  'p-as-heading': {
3916
3913
  description: 'Ensure p elements are not used to style headings',
3917
- help:
3918
- 'Bold, italic text and font-size are not used to style p elements as a heading'
3914
+ help: 'Bold, italic text and font-size are not used to style p elements as a heading'
3919
3915
  },
3920
3916
  radiogroup: {
3921
3917
  description:
3922
3918
  'Ensures related <input type="radio"> elements have a group and that the group designation is consistent',
3923
- help:
3924
- 'Radio inputs with the same name attribute value must be part of a group'
3919
+ help: 'Radio inputs with the same name attribute value must be part of a group'
3925
3920
  },
3926
3921
  region: {
3927
3922
  description:
@@ -3949,32 +3944,27 @@
3949
3944
  'table-duplicate-name': {
3950
3945
  description:
3951
3946
  'Ensure that tables do not have the same summary and caption',
3952
- help:
3953
- 'The <caption> element should not contain the same text as the summary attribute'
3947
+ help: 'The <caption> element should not contain the same text as the summary attribute'
3954
3948
  },
3955
3949
  'table-fake-caption': {
3956
3950
  description:
3957
3951
  'Ensure that tables with a caption use the <caption> element.',
3958
- help:
3959
- 'Data or header cells should not be used to give caption to a data table.'
3952
+ help: 'Data or header cells should not be used to give caption to a data table.'
3960
3953
  },
3961
3954
  'td-has-header': {
3962
3955
  description:
3963
3956
  'Ensure that each non-empty data cell in a large table has one or more table headers',
3964
- help:
3965
- 'All non-empty td element in table larger than 3 by 3 must have an associated table header'
3957
+ help: 'All non-empty td element in table larger than 3 by 3 must have an associated table header'
3966
3958
  },
3967
3959
  'td-headers-attr': {
3968
3960
  description:
3969
3961
  'Ensure that each cell in a table using the headers refers to another cell in that table',
3970
- help:
3971
- 'All cells in a table element that use the headers attribute must only refer to other cells of that same table'
3962
+ help: 'All cells in a table element that use the headers attribute must only refer to other cells of that same table'
3972
3963
  },
3973
3964
  'th-has-data-cells': {
3974
3965
  description:
3975
3966
  'Ensure that each table header in a data table refers to data cells',
3976
- help:
3977
- 'All th elements and elements with role=columnheader/rowheader must have data cells they describe'
3967
+ help: 'All th elements and elements with role=columnheader/rowheader must have data cells they describe'
3978
3968
  },
3979
3969
  'valid-lang': {
3980
3970
  description: 'Ensures lang attributes have valid values',
@@ -9136,29 +9126,27 @@
9136
9126
  }
9137
9127
  return set;
9138
9128
  };
9139
- var sortRolesByOptimalAriaContext = function sortRolesByOptimalAriaContext(
9140
- roles,
9141
- ariaAttributes
9142
- ) {
9143
- var getScore = function getScore(role) {
9144
- var allowedAriaAttributes = aria.allowedAttr(role);
9145
- return allowedAriaAttributes.reduce(function (score, attribute) {
9146
- return score + (ariaAttributes.indexOf(attribute) > -1 ? 1 : 0);
9147
- }, 0);
9148
- };
9149
- var scored = roles.map(function (role) {
9150
- return {
9151
- score: getScore(role),
9152
- name: role
9129
+ var sortRolesByOptimalAriaContext =
9130
+ function sortRolesByOptimalAriaContext(roles, ariaAttributes) {
9131
+ var getScore = function getScore(role) {
9132
+ var allowedAriaAttributes = aria.allowedAttr(role);
9133
+ return allowedAriaAttributes.reduce(function (score, attribute) {
9134
+ return score + (ariaAttributes.indexOf(attribute) > -1 ? 1 : 0);
9135
+ }, 0);
9153
9136
  };
9154
- });
9155
- var sorted = scored.sort(function (scoredRoleA, scoredRoleB) {
9156
- return scoredRoleB.score - scoredRoleA.score;
9157
- });
9158
- return sorted.map(function (sortedRole) {
9159
- return sortedRole.name;
9160
- });
9161
- };
9137
+ var scored = roles.map(function (role) {
9138
+ return {
9139
+ score: getScore(role),
9140
+ name: role
9141
+ };
9142
+ });
9143
+ var sorted = scored.sort(function (scoredRoleA, scoredRoleB) {
9144
+ return scoredRoleB.score - scoredRoleA.score;
9145
+ });
9146
+ return sorted.map(function (sortedRole) {
9147
+ return sortedRole.name;
9148
+ });
9149
+ };
9162
9150
  var roles = Object.keys(lookupTables.role).map(function (role) {
9163
9151
  var lookup = lookupTables.role[role];
9164
9152
  return {
package/src/types.ts CHANGED
@@ -23,6 +23,7 @@ export interface WebdriverConfigParams {
23
23
  browser: string;
24
24
  timeout: number;
25
25
  chromedriverPath?: string;
26
+ chromePath?: string;
26
27
  path?: string;
27
28
  chromeOptions?: string[];
28
29
  builder?: Builder;