diff --git a/docs/05-command-line.md b/docs/05-command-line.md index a1ca86e31..c3a2d7994 100644 --- a/docs/05-command-line.md +++ b/docs/05-command-line.md @@ -30,7 +30,7 @@ $ npx ava --help The above relies on your shell expanding the glob patterns. Without arguments, AVA uses the following patterns: - **/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js + **/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/tests/**/*.js **/__tests__/**/*.js ``` *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: * `**/*.spec.js` * `**/*.test.js` * `**/test/**/*.js` +* `**/tests/**/*.js` * `**/__tests__/**/*.js` Files inside `node_modules` are *always* ignored. So are files starting with `_`. These are treated as helpers. diff --git a/lib/cli.js b/lib/cli.js index c873073b6..de2946049 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -52,7 +52,7 @@ exports.run = async () => { // eslint-disable-line complexity The above relies on your shell expanding the glob patterns. Without arguments, AVA uses the following patterns: - **/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js + **/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/tests/**/*.js **/__tests__/**/*.js `, { flags: { watch: { diff --git a/lib/globs.js b/lib/globs.js index d3825bfe7..0c2eea197 100644 --- a/lib/globs.js +++ b/lib/globs.js @@ -48,7 +48,8 @@ function normalizeGlobs(testPatterns, helperPatterns, sourcePatterns, extensions `**/*.test.${extensionPattern}`, `**/test-*.${extensionPattern}`, `**/test.${extensionPattern}`, - `**/test/**/*.${extensionPattern}` + `**/test/**/*.${extensionPattern}`, + `**/tests/**/*.${extensionPattern}` ]; if (testPatterns) { diff --git a/test/fixture/globs/default-patterns/tests/_foo-help.js b/test/fixture/globs/default-patterns/tests/_foo-help.js new file mode 100644 index 000000000..d15abba59 --- /dev/null +++ b/test/fixture/globs/default-patterns/tests/_foo-help.js @@ -0,0 +1 @@ +// Empty diff --git a/test/fixture/globs/default-patterns/tests/baz.js b/test/fixture/globs/default-patterns/tests/baz.js new file mode 100644 index 000000000..d15abba59 --- /dev/null +++ b/test/fixture/globs/default-patterns/tests/baz.js @@ -0,0 +1 @@ +// Empty diff --git a/test/fixture/globs/default-patterns/tests/deep/deep.js b/test/fixture/globs/default-patterns/tests/deep/deep.js new file mode 100644 index 000000000..d15abba59 --- /dev/null +++ b/test/fixture/globs/default-patterns/tests/deep/deep.js @@ -0,0 +1 @@ +// Empty diff --git a/test/fixture/globs/default-patterns/tests/fixtures/foo-fixt.js b/test/fixture/globs/default-patterns/tests/fixtures/foo-fixt.js new file mode 100644 index 000000000..d15abba59 --- /dev/null +++ b/test/fixture/globs/default-patterns/tests/fixtures/foo-fixt.js @@ -0,0 +1 @@ +// Empty diff --git a/test/fixture/globs/default-patterns/tests/helpers/test.js b/test/fixture/globs/default-patterns/tests/helpers/test.js new file mode 100644 index 000000000..d15abba59 --- /dev/null +++ b/test/fixture/globs/default-patterns/tests/helpers/test.js @@ -0,0 +1 @@ +// Empty diff --git a/test/globs.js b/test/globs.js index f6cd74189..caa7bd57d 100644 --- a/test/globs.js +++ b/test/globs.js @@ -270,7 +270,9 @@ test('findHelpersAndTests finds tests (just .js)', async t => { 'test-foo.js', 'test.js', 'test/baz.js', - 'test/deep/deep.js' + 'test/deep/deep.js', + 'tests/baz.js', + 'tests/deep/deep.js' ].map(file => path.join(fixtureDir, file)).sort(); const {tests: actual} = await globs.findHelpersAndTests({ @@ -307,7 +309,9 @@ test('findHelpersAndTests finds helpers (just .js)', async t => { 'sub/directory/__tests__/helpers/foo.js', 'sub/directory/__tests__/_foo.js', 'test/helpers/test.js', - 'test/_foo-help.js' + 'test/_foo-help.js', + 'tests/_foo-help.js', + 'tests/helpers/test.js' ].sort().map(file => path.join(fixtureDir, file)); const {helpers: actual} = await globs.findHelpersAndTests({ @@ -347,7 +351,9 @@ test('findTests finds tests (just .js)', async t => { 'test-foo.js', 'test.js', 'test/baz.js', - 'test/deep/deep.js' + 'test/deep/deep.js', + 'tests/baz.js', + 'tests/deep/deep.js' ].map(file => path.join(fixtureDir, file)).sort(); const {tests: actual} = await globs.findTests({