Skip to content

Commit 89a5abf

Browse files
authored
Infrastructure: add Ava ESLint plug-in with recommended rules (pull #1566)
* add ava ESLint plug-in * fix: Ava ESLint recommended cleanups * No strict declaration in Ava module files * Ignore the "index" test file as it isn't directly called * Fix async/await functions * `after.always` hook must come before `beforeEach`
1 parent c4d8d14 commit 89a5abf

File tree

71 files changed

+85
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+85
-145
lines changed

package-lock.json

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"cspell": "^4.1.2",
3636
"eslint": "^7.11.0",
3737
"eslint-config-prettier": "^6.12.0",
38+
"eslint-plugin-ava": "^11.0.0",
3839
"eslint-plugin-prettier": "^3.1.4",
3940
"geckodriver": "^1.20.0",
4041
"glob": "^7.1.6",

test/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../.eslintrc.json",
2+
"extends": ["../.eslintrc.json", "plugin:ava/recommended"],
33
"parserOptions": {
44
"ecmaVersion": 8
55
}

test/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
/* eslint-disable ava/no-ignored-test-files */
22

33
const path = require('path');
44
const test = require('ava');
@@ -29,18 +29,22 @@ if (!coverageReportRun) {
2929
await session;
3030
});
3131

32+
test.after.always(async () => {
33+
if (session) {
34+
await session.close();
35+
}
36+
37+
if (geckodriver) {
38+
await geckodriver.stop();
39+
}
40+
});
41+
3242
test.beforeEach((t) => {
3343
t.context.session = session;
3444
t.context.waitTime = testWaitTime;
3545
t.context.queryElement = queryElement;
3646
t.context.queryElements = queryElements;
3747
});
38-
39-
test.after.always(() => {
40-
return Promise.resolve(session && session.close()).then(
41-
() => geckodriver && geckodriver.stop()
42-
);
43-
});
4448
}
4549

4650
/**
@@ -75,7 +79,7 @@ const _ariaTest = (desc, page, testId, body, failing) => {
7579
const testName = page + ' ' + selector + ': ' + desc;
7680

7781
if (coverageReportRun) {
78-
test(testName, async function (t) {
82+
test(testName, function (t) {
7983
t.fail('All tests expect to fail. Running in coverage mode.');
8084
});
8185
return;

test/tests/accordion_accordion.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By, Key } = require('selenium-webdriver');
53
const assertAriaControls = require('../util/assertAriaControls');

test/tests/alert_alert.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By } = require('selenium-webdriver');
53

test/tests/breadcrumb_index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By } = require('selenium-webdriver');
53
const assertAriaLabelExists = require('../util/assertAriaLabelExists');

test/tests/button_button.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By, Key } = require('selenium-webdriver');
53

test/tests/carousel_carousel-1-prev-next.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By, Key } = require('selenium-webdriver');
53
const assertAttributeValues = require('../util/assertAttributeValues');

test/tests/carousel_carousel-2-tablist.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const { ariaTest } = require('..');
42
const { By, Key } = require('selenium-webdriver');
53
const assertAttributeValues = require('../util/assertAttributeValues');

0 commit comments

Comments
 (0)