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
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,44 @@
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.
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.
8
+
9
+
Also note that this rule will not do anything if you don't have a `package.json` file in your project.
5
10
6
11
## Fail
7
12
8
13
```js
9
14
// File: test/foo/fixtures/bar.js
15
+
// Invalid because in `fixtures` folder
10
16
importtestfrom'ava';
11
17
12
18
test('foo', t=> {
13
19
t.pass();
14
20
});
15
21
16
22
// File: test/foo/helpers/bar.js
23
+
// Invalid because in `helpers` folder
24
+
importtestfrom'ava';
25
+
26
+
test('foo', t=> {
27
+
t.pass();
28
+
});
29
+
30
+
// File: lib/foo.test.js
31
+
// Invalid because not in the searched files
32
+
importtestfrom'ava';
33
+
34
+
test('foo', t=> {
35
+
t.pass();
36
+
});
37
+
38
+
// File: test.js
39
+
// with { "files": ["lib/**/*.test.js", "utils/**/*.test.js"] }
40
+
// in either `package.json` under 'ava key' or in the rule options
41
+
// Invalid because not in the searched files
17
42
importtestfrom'ava';
18
43
19
44
test('foo', t=> {
@@ -38,4 +63,32 @@ import test from 'ava';
38
63
test('foo', t=> {
39
64
t.pass();
40
65
});
66
+
67
+
// File: test.js
68
+
importtestfrom'ava';
69
+
70
+
test('foo', t=> {
71
+
t.pass();
72
+
});
73
+
74
+
// File: lib/foo.test.js
75
+
// with { "files": ["lib/**/*.test.js", "utils/**/*.test.js"] }
76
+
// in either `package.json` under 'ava key' or in the rule options
77
+
importtestfrom'ava';
78
+
79
+
test('foo', t=> {
80
+
t.pass();
81
+
});
82
+
```
83
+
84
+
## Options
85
+
86
+
This rule supports the following options:
87
+
88
+
`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