VueCLI forces Jest's testMatch option
See original GitHub issueVersion
3.0.0-beta.6
Reproduction link
https://github.com/Ldoppea/vue-cli-jest-testmatch
Steps to reproduce
Init project with following options :
Vue CLI v3.0.0-beta.6
? Please pick a preset: Manually select features
? Check the features needed for your project: Unit
? Pick a unit testing solution: Jest
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? (Y/n) n
Move /tests/unit/HelloWorld.spec.js
in /src/components/
Add testMatch
in package.json Jest category :
"testMatch": [
"test/**/*.spec.js",
"src/**/*.spec.js"
]
Run npm run test
What is expected?
HelloWorld.spec.js should be tested
What is actually happening?
No test is found by Jest. Get the following error :
No tests found
In D:\Work\test\vue\testJest
6 files checked.
testMatch: D:\Work\test\vue\testJest\(tests\unit\**\*.spec.(ts|tsx|js)|**\__tests__\*.(ts|tsx|js)) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 6 matches
Pattern: - 0 matches
ERROR jest exited with code 1.
testMatch still has the value forced by vueCLI
I was able to run my tests from src
folder and without using testMatch
on vueCLI@3.0.0-beta.4. This commit changed the test detection behavior : https://github.com/vuejs/vue-cli/commit/2c61d236d77dfcb22b4560afe4c957ddf45b4337#diff-17aae08cfc13cba07661681220ddd985 (I do not use typescript)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:8 (3 by maintainers)
Top Results From Across the Web
vue/cli-plugin-unit-jest
Run unit tests with Jest. Default testMatch is <rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)) which matches ...
Read more >Jest CLI Options
Jest CLI Options. The jest command line runner has a number of useful options. You can run jest --help to view all available...
Read more >@vue/cli-plugin-unit-jest | Yarn - Package Manager
Run unit tests with Jest. Default testMatch is <rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx) ...
Read more >vue-cli default unit tests "Unexpected token {" error
I just asked a similar question, here ( there is an answer in that one towards the bottom ). I see in your...
Read more >Configuring Jest compiled - w3resource
Always remember that the resulting configuration must be JSON-serializable. When you are using the --config option, the JSON file should not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It appears that the plugin always sets the testMatch to
[`--testMatch`, `<rootDir>/(tests/unit/**/*.spec.(ts|tsx|js)|**/__tests__/*.(ts|tsx|js))`]
if none is specified via a command line argument, instead of respecting anything set in package.json. If we would like to respect those configurations, it appears to be an easy enough tweak I would gladly contributeWith my current PR (#1069) that is what I ended up doing. I moved the testMatch pattern over to the generator so that it goes into the package.json or jest.config.js (depending on how the user wants their config files laid out)