vue-cli: Tests are not found out of the box
Version
3.0.0-rc.3
Reproduction link
https://would-not-be-useful.com could not find a good way to do this - I think it must be related to some other setting.
Steps to reproduce
vue create test_app -> choose babel and jest
yarn unit:test
yarn run v1.7.0
$ vue-cli-service test:unit
No tests found
In /Users/lachlanmiller/javascript/vue/qiita_post
10 files checked.
testMatch: /Users/lachlanmiller/javascript/vue/qiita_post/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)) - 0 matches
testPathIgnorePatterns: /node_modules/ - 10 matches
Pattern: - 0 matches
ERROR jest exited with code 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What is expected?
It runs HelloWorld.spec.js
What is actually happening?
It does not find the test
MacOS 10.13.2 High Sierra Happening on another machine (not sure of the macOS version for it, but it’s high sierra). I can check the version tomorrow. I tried using both npm and yarn, and jest directly.
I tried both with jest config in package.json and standalone.
Also I cannot specify either:
yarn test:unit -- --runTestsByPath tests/unit/HelloWorld.spec.js
> vue-cli-service test:unit "--runTestsByPath" "tests/unit/HelloWorld.spec.js"
No tests found
No files found in /Users/lachlanmiller/javascript/vue/qiita_post.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Files: "tests/unit/HelloWorld.spec.js"
HOWEVER git cloning a project scaffolded on another PC works somehow.
Other projects on my machine are using jest no problem. Not sure what’s going on. Any ideas?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (3 by maintainers)
Hi, the same happened to me on MacOS 10.13.4 High Sierra, I removed the enclosing round brackets in
jest.config.jsand it works. basically, this works:Not working /:
For people having this issue, the latest version of Jest doesn’t like the
<rootdir>in testMatch. This happened in Jest 23/24, so if you built your jest.config.js file in and older version of Jest, then upgraded to Jest latest, you will have this issue.Use something like this instead:
Breaking changes like this would be nice if Jest warned you that the devs decided to implement a breaking change, instead of just giving cryptic errors when the developer does nothing wrong.
Stuff like this makes all Jest 22 and previous source code that includes a jest.config.js file broken, for example. How is this good for the community?
hello, I have same problem on windows 10, however, I can run test correctly in the following way
The issue on windows seems to be caused by the fact that jest v23 uses micromatch v3.1.10, while jest v22 used micromatch v2.3.11.
@mario-d-s
I scaffolded a vue-cli 3 app about ~2 weeks ago and my
jest.config.jsfile looked like this:When I scaffolded a new app today,
jest.config.jsnow looks likeNote the difference between the testMatch array.
@allochi not working neither, but I’m on Windows 10 Exactly the same problem as described as @lmiller1990
On Ubuntu I have the same problem, I just add an additional path to
If you plan to have all your tests in
/tests/unit/, just use: