You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-ignored-test-files.md
+52-1Lines changed: 52 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,42 @@
1
1
# Ensure no tests are written in ignored files
2
2
3
-
When searching for tests, AVA ignores files contained in folders named `fixtures` or `helpers`.
3
+
When searching for tests, AVA ignores files contained in folders named `fixtures` or `helpers`. By default, it will search in `test.js test-*.js test/**/*.js`, which you can override by specifying a path when launching AVA or in the [AVA configuration in the `package.json` file]](https://github.com/sindresorhus/ava#configuration).
4
4
5
+
This rule will verify that files which create tests are in the searched files and not in ignored folders. It will consider the root of the project to be the closest folder containing a `package.json` file, and will not do anything if it can't find one.
6
+
7
+
Note that this rule will not be able to warn correctly if you use AVA by specifying the files in the command line ( `ava "lib/**/*.test.js"` ). Prefer configuring AVA as described in the link above.
5
8
6
9
## Fail
7
10
8
11
```js
9
12
// File: test/foo/fixtures/bar.js
13
+
// Invalid because in `fixtures` folder
10
14
importtestfrom'ava';
11
15
12
16
test('foo', t=> {
13
17
t.pass();
14
18
});
15
19
16
20
// File: test/foo/helpers/bar.js
21
+
// Invalid because in `helpers` folder
22
+
importtestfrom'ava';
23
+
24
+
test('foo', t=> {
25
+
t.pass();
26
+
});
27
+
28
+
// File: lib/foo.test.js
29
+
// Invalid because not in the searched files
30
+
importtestfrom'ava';
31
+
32
+
test('foo', t=> {
33
+
t.pass();
34
+
});
35
+
36
+
// File: test.js
37
+
// with { "files": ["lib/**/*.test.js", "utils/**/*.test.js"] }
38
+
// in either `package.json` under 'ava key' or in the rule options
39
+
// Invalid because not in the searched files
17
40
importtestfrom'ava';
18
41
19
42
test('foo', t=> {
@@ -38,4 +61,32 @@ import test from 'ava';
38
61
test('foo', t=> {
39
62
t.pass();
40
63
});
64
+
65
+
// File: test.js
66
+
importtestfrom'ava';
67
+
68
+
test('foo', t=> {
69
+
t.pass();
70
+
});
71
+
72
+
// File: lib/foo.test.js
73
+
// with { "files": ["lib/**/*.test.js", "utils/**/*.test.js"] }
74
+
// in either `package.json` under 'ava key' or in the rule options
75
+
importtestfrom'ava';
76
+
77
+
test('foo', t=> {
78
+
t.pass();
79
+
});
80
+
```
81
+
82
+
## Options
83
+
84
+
This rule supports the following options:
85
+
86
+
`files`: An array of strings representing the files glob that AVA will use to find test files. Overrides the default and the configuration found in the `package.json` file.
0 commit comments