Skip to content

Commit

Permalink
Treat .spec.js files as test files
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed May 5, 2019
1 parent 91b7641 commit 08e99e5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/05-command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 **/*.test.js **/test/**/*.js **/__tests__/**/*.js
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js
```

*Note that the CLI will use your local install of AVA when available, even when run globally.*
Expand All @@ -39,6 +39,7 @@ AVA searches for test files using the following patterns:

* `**/test.js`
* `**/test-*.js`
* `**/*.spec.js`
* `**/*.test.js`
* `**/test/**/*.js`
* `**/__tests__/**/*.js`
Expand Down
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 **/*.test.js **/test/**/*.js **/__tests__/**/*.js
**/test.js **/test-*.js **/*.spec.js **/*.test.js **/test/**/*.js **/__tests__/**/*.js
`, {
flags: {
watch: {
Expand Down
1 change: 1 addition & 0 deletions lib/globs.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function normalizeGlobs(testPatterns, sourcePatterns, extensions) {
const extensionPattern = buildExtensionPattern(extensions);
const defaultTestPatterns = [
`**/__tests__/**/*.${extensionPattern}`,
`**/*.spec.${extensionPattern}`,
`**/*.test.${extensionPattern}`,
`**/test-*.${extensionPattern}`,
`**/test.${extensionPattern}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty
1 change: 1 addition & 0 deletions test/globs.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ test('findHelpersAndTests finds tests (just .js)', async t => {

const expected = [
'sub/directory/__tests__/foo.js',
'sub/directory/bar.spec.js',
'sub/directory/bar.test.js',
'test-foo.js',
'test.js',
Expand Down

0 comments on commit 08e99e5

Please sign in to comment.