Skip to content

Commit

Permalink
test: fix aria practices tests not running (#3922)
Browse files Browse the repository at this point in the history
* tests: fix aria practices tests not running

* add --zero-fail option
  • Loading branch information
straker authored Feb 28, 2023
1 parent d4522cd commit 2ba2ae9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 62 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@
"test:unit:integration": "npm run test:unit -- testDirs=integration",
"test:unit:virtual-rules": "npm run test:unit -- testDirs=virtual-rules",
"integration": "node test/integration/full/test-webdriver.js",
"integration:apg": "mocha test/aria-practices/*.spec.js",
"integration:apg": "mocha --fail-zero test/aria-practices/*.spec.js",
"integration:chrome": "npm run integration -- browser=Chrome",
"integration:firefox": "npm run integration -- browser=Firefox",
"test:integration": "npm run test:integration:chrome",
"test:integration:chrome": "start-server-and-test 9876 integration:chrome",
"test:integration:firefox": "start-server-and-test 9876 integration:firefox",
"test:examples": "node ./doc/examples/test-examples",
"test:act": "mocha test/act-rules/*.spec.js",
"test:act": "mocha --fail-zero test/act-rules/*.spec.js",
"test:apg": "start-server-and-test 9876 integration:apg",
"test:locales": "mocha test/test-locales.js",
"test:virtual-rules": "mocha test/test-virtual-rules.js",
Expand Down
11 changes: 1 addition & 10 deletions test/act-rules/act-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ const path = require('path');
const fs = require('fs');
const http = require('http');
const handler = require('serve-handler');
const chromedriver = require('chromedriver');
const AxeBuilder = require('@axe-core/webdriverjs');
const {
getWebdriver,
connectToChromeDriver
} = require('../aria-practices/run-server');
const { getWebdriver } = require('../get-webdriver');
const { assert } = require('chai');

const driverPort = 9515;
const serverPort = 9898;
const axePath = require.resolve('../../axe.js');
const axeSource = fs.readFileSync(axePath, 'utf8');
Expand All @@ -34,9 +29,6 @@ module.exports = ({ id, title, axeRules, skipTests = [] }) => {
this.retries(3);

before(async () => {
chromedriver.start([`--port=${driverPort}`]);
await new Promise(r => setTimeout(r, 500));
await connectToChromeDriver(driverPort);
driver = getWebdriver();
});

Expand All @@ -59,7 +51,6 @@ module.exports = ({ id, title, axeRules, skipTests = [] }) => {

after(async () => {
await driver.close();
chromedriver.stop();
await new Promise(r => server.close(r));
});

Expand Down
8 changes: 1 addition & 7 deletions test/aria-practices/apg.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const path = require('path');
const fs = require('fs');
const chromedriver = require('chromedriver');
const AxeBuilder = require('@axe-core/webdriverjs');
const { getWebdriver, connectToChromeDriver } = require('./run-server');
const { getWebdriver } = require('../get-webdriver');
const { assert } = require('chai');
const globby = require('globby');

Expand All @@ -13,7 +12,6 @@ describe('aria-practices', function () {
const testFiles = filePaths.map(
fileName => fileName.split('/aria-practices/examples/')[1]
);
const port = 9515;
const addr = `http://localhost:9876/node_modules/aria-practices/`;
let driver, axeSource;
this.timeout(50000);
Expand All @@ -22,15 +20,11 @@ describe('aria-practices', function () {
before(async () => {
const axePath = require.resolve('../../axe.js');
axeSource = fs.readFileSync(axePath, 'utf8');
chromedriver.start([`--port=${port}`]);
await new Promise(r => setTimeout(r, 500));
await connectToChromeDriver(port);
driver = getWebdriver();
});

after(async () => {
await driver.close();
chromedriver.stop();
});

const disabledRules = {
Expand Down
43 changes: 0 additions & 43 deletions test/aria-practices/run-server.js

This file was deleted.

16 changes: 16 additions & 0 deletions test/get-webdriver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const chromedriverPath = require('chromedriver').path;

const getWebdriver = () => {
const service = new chrome.ServiceBuilder(chromedriverPath);

const webdriver = new Builder()
.setChromeOptions(new chrome.Options().headless())
.forBrowser('chrome')
.setChromeService(service)
.build();
return webdriver;
};

module.exports.getWebdriver = getWebdriver;

0 comments on commit 2ba2ae9

Please sign in to comment.