Skip to content

Commit b1e54b1

Browse files
committed
By default, select test and helpers inside 'tests' directories
1 parent 677578f commit b1e54b1

File tree

9 files changed

+19
-6
lines changed

9 files changed

+19
-6
lines changed

docs/05-command-line.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ npx ava --help
3030

3131
The above relies on your shell expanding the glob patterns.
3232
Without arguments, AVA uses the following patterns:
33-
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js
33+
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/tests/**/*.js **/__tests__/**/*.js
3434
```
3535

3636
*Note that the CLI will use your local install of AVA when available, even when run globally.*
@@ -42,6 +42,7 @@ AVA searches for test files using the following patterns:
4242
* `**/*.spec.js`
4343
* `**/*.test.js`
4444
* `**/test/**/*.js`
45+
* `**/tests/**/*.js`
4546
* `**/__tests__/**/*.js`
4647

4748
Files inside `node_modules` are *always* ignored. So are files starting with `_`. These are treated as helpers.

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exports.run = async () => { // eslint-disable-line complexity
5252
5353
The above relies on your shell expanding the glob patterns.
5454
Without arguments, AVA uses the following patterns:
55-
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js
55+
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/tests/**/*.js **/__tests__/**/*.js
5656
`, {
5757
flags: {
5858
watch: {

lib/globs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function normalizeGlobs(testPatterns, helperPatterns, sourcePatterns, extensions
4848
`**/*.test.${extensionPattern}`,
4949
`**/test-*.${extensionPattern}`,
5050
`**/test.${extensionPattern}`,
51-
`**/test/**/*.${extensionPattern}`
51+
`**/test/**/*.${extensionPattern}`,
52+
`**/tests/**/*.${extensionPattern}`
5253
];
5354

5455
if (testPatterns) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty

test/globs.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ test('findHelpersAndTests finds tests (just .js)', async t => {
270270
'test-foo.js',
271271
'test.js',
272272
'test/baz.js',
273-
'test/deep/deep.js'
273+
'test/deep/deep.js',
274+
'tests/baz.js',
275+
'tests/deep/deep.js'
274276
].map(file => path.join(fixtureDir, file)).sort();
275277

276278
const {tests: actual} = await globs.findHelpersAndTests({
@@ -307,7 +309,9 @@ test('findHelpersAndTests finds helpers (just .js)', async t => {
307309
'sub/directory/__tests__/helpers/foo.js',
308310
'sub/directory/__tests__/_foo.js',
309311
'test/helpers/test.js',
310-
'test/_foo-help.js'
312+
'test/_foo-help.js',
313+
'tests/_foo-help.js',
314+
'tests/helpers/test.js'
311315
].sort().map(file => path.join(fixtureDir, file));
312316

313317
const {helpers: actual} = await globs.findHelpersAndTests({
@@ -347,7 +351,9 @@ test('findTests finds tests (just .js)', async t => {
347351
'test-foo.js',
348352
'test.js',
349353
'test/baz.js',
350-
'test/deep/deep.js'
354+
'test/deep/deep.js',
355+
'tests/baz.js',
356+
'tests/deep/deep.js'
351357
].map(file => path.join(fixtureDir, file)).sort();
352358

353359
const {tests: actual} = await globs.findTests({

0 commit comments

Comments
 (0)