When specifying glob pattern, test files 2 directories deep are ignored
See original GitHub issueDescription
Thanks for working on AVA! I’m enjoying it very much so far. I’ve run into an edge case with globbing patterns, and have put up a repository reproducing the issue: https://github.com/coopy/ava-test-glob-repro
Overview
I have a source tree that looks like this (with test files in asrc/modules/deeper/
directory):
src
├── lib
│ ├── dep.js
│ └── dep.test.js
└── modules
└── deeper
├── add.js
└── add.test.js
When I run $ ava
with defaults, all is good and tests are found and run.
Issue: When I run AVA with a file globbing pattern specified, only the tests in the shallower directory (lib/
) are run .
$ ava src/**/*.test.js
Test Source
See full repro here: https://github.com/coopy/ava-test-glob-repro
Error Message & Stack Trace
Running with file pattern (DOESN’T WORK AS EXPECTED)
$ ava src/**/*.test.js --verbose
✔ should return configuration
1 test passed
Running with defaults (WORKS AS EXPECTED)
$ ava --verbose
✔ lib › dep › should return configuration
✔ modules › deeper › add › should add two numbers
2 tests passed
Config
Copy the relevant section from package.json
:
{
"name": "ava-test-glob-repro",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "ava src/**/*.test.js --verbose"
},
"author": "",
"license": "MIT",
"description": "",
"devDependencies": {
"ava": "^0.24.0"
},
"dependencies": {
"node-glob": "^1.2.0"
}
}
Command-Line Arguments
Copy your npm build scripts or the ava
command used:
ava src/**/*.test.js --verbose
Relevant Links
https://github.com/coopy/ava-test-glob-repro
Environment
Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:
$ node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
darwin 17.3.0
$ ava --version
0.24.0
$ npm --version
5.6.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (7 by maintainers)
@coopy thanks for the excellent issue report!
Most likely your shell is expanding the pattern, not AVA. Try quoting the patterns instead:
This works for me. (Closing this issue but please let me know if this helps!)
@cdaringe, in v1, you could pass directories and AVA would try and find test files inside of them. Combined with customizable file extensions it became quite hard to understand which files would be selected.
If Babel is enabled, AVA precompiles all test files based on the
files
configuration. It’s simpler to reason that the CLI should receive files to execute without those necessarily impacting the pre-compilation.Our bias for the CLI has been that configuration you always use should be in a configuration file, not a CLI argument. Thus, the CLI supports only a subset of the configuration.
Arguably I over-estimated how many people used globs on the CLI, even as a
package.json
run script, rather that configuringfiles
. Though hopefully now that you can select which configuration to use through the CLI we’ve addressed most of those use cases.