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.

testMatch doesn't glob as expected

See original GitHub issue

i’m setting up jest’s testMatch config, but it doesn’t glob as expected. my sanity-check command looks into the test folder relative to the project, goes to any depth, and selects any file that ends in .js:

ls ./test/**/*.js | wc -l

running that returns 92. which makes sense, i have 92 files in that directory structure (some tests and some test utils). but when i run jest with the same glob it says there are no tests found:

yarn run v1.9.4
$ jest --config jest.config.json
No tests found
In /Users/<user>/<repo>
  460 files checked.
  testMatch: ./test/**/*.js - 0 matches
  testPathIgnorePatterns: /node_modules/ - 460 matches
Pattern:  - 0 matches
error Command failed with exit code 1.

is this an issue with jest? with micromatch?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
lohfucommented, Mar 27, 2020

I too have problems with the testMatch globbing.

Changing the built in:

testMatch: [
  "**/__tests__/**/*.[jt]s?(x)",
  "**/?(*.)+(spec|test).[tj]s?(x)"
],

to

testMatch: [
  "src/**/__tests__/**/*.[jt]s?(x)",
  "src/**/?(*.)+(spec|test).[tj]s?(x)"
],

will cause no files to be matches. To resolve this i have to:

testMatch: [
  path.join(__dirname, 'src/**/__tests__/**/*.[jt]s?(x)'),
  path.join(__dirname, 'src/**/?(*.)+(spec|test).[tj]s?(x)'),
],
2reactions
rickhanloniicommented, Oct 10, 2018

Thanks!

We can look into why those globs don’t work - just wanted to verify that it’s the relative pathing

Read more comments on GitHub >

github_iconTop Results From Across the Web

testMatch glob pattern unexpected behaviour - Stack Overflow
The glob patterns Jest uses to detect test files testMatch: [ '**/test/*.ts' ],. This isn't working as expected however.
Read more >
Configuring Jest
Insert Jest's globals ( expect , test , describe , beforeEach etc.) into the global environment. If you set this to false ,...
Read more >
Using Jest with Playwright
See here as a reference for the testRegex and testMatch setting. ... For every test beforeEach will create a new page as a...
Read more >
Configuring Jest
An array of glob patterns indicating a set of files for which coverage ... See also testMatch [array<string>], but note that you cannot...
Read more >
Investment Commentary Tax Efficient Wealth Management
expected returns and tax assumptions that ... the pre-tax expected return for global equity ... does not justify maintaining a suboptimal.
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