Skip to content

Commit da0a580

Browse files
authored
Forbid exclusive tests (#94)
Forgetting to remove the `.only` method on a test can result in a reduced test coverage. Introduce a minimal ESLint config for tests which checks for exclusive tests. No other linting rules are enabled for now because our test files haven't been linted in the past and there's a lot to fix.
1 parent cc32a1e commit da0a580

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

common.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ all: lint test build
1515
dist: lint test build html
1616

1717
lint:
18-
@eslint --max-warnings 0 src/
18+
@eslint --config $(ROOT)/eslint_src.json --max-warnings 0 src/
19+
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
1920
@echo -e " $(OK) $@"
2021

2122
test:
File renamed without changes.

eslint_test.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 8,
4+
"sourceType": "module",
5+
"ecmaFeatures": {
6+
"jsx": true
7+
}
8+
},
9+
"env": {
10+
"es6": true,
11+
"node": true,
12+
"mocha": true
13+
},
14+
"plugins": [
15+
"mocha"
16+
],
17+
"rules": {
18+
"mocha/no-exclusive-tests": "error",
19+
"mocha/no-identical-title": "error"
20+
}
21+
}

fluent/test/functions_builtin_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ suite('Built-in functions', function() {
8383
assert.equal(ctx.format(msg), 'Invalid Date');
8484
});
8585

86-
test.only('Date argument', function() {
86+
test('Date argument', function () {
8787
const date = new Date('2016-09-29');
8888
// format the date argument to account for the testrunner's timezone
8989
const expectedDefault =

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"commander": "^2.9",
1414
"documentation": "^4.0.0-beta10",
1515
"eslint": "^3.19.0",
16+
"eslint-plugin-mocha": "^4.11.0",
1617
"fuzzer": "^0.2.1",
1718
"gh-pages": "^0.12.0",
1819
"jsdoc": "^3.5.4",

0 commit comments

Comments
 (0)