question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When specifying glob pattern, test files 2 directories deep are ignored

See original GitHub issue

Description

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:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
novemberborncommented, Jan 2, 2018

@coopy thanks for the excellent issue report!

Most likely your shell is expanding the pattern, not AVA. Try quoting the patterns instead:

$ ava 'src/**/*.test.js' --verbose

This works for me. (Closing this issue but please let me know if this helps!)

1reaction
novemberborncommented, Aug 26, 2019

@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 configuring files. Though hopefully now that you can select which configuration to use through the CLI we’ve addressed most of those use cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips for writing glob patterns in DeepSource configuration
Test patterns and exclude patterns are optional, yet important parts of the .deepsource.toml configuration file. They are written as glob ...
Read more >
ZSH: Recursive globbing excluding specified hidden directories
The easiest way to make a glob pattern match dot files is to use the D glob qualifier. **/*(D). The precedence of ~...
Read more >
Ignoring Code - ESLint - Pluggable JavaScript Linter
You can configure ESLint to ignore certain files and directories while linting by specifying one or more glob patterns. You can ignore files...
Read more >
Glob ignore node test files - Stack Overflow
I try create a glob for get only code files vue and js , but I unknown like retire spec and test files...
Read more >
gitignore Documentation - Git
Each line in a gitignore file specifies a pattern. When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found