-
Notifications
You must be signed in to change notification settings - Fork 157
Jest requires --no-cache
for proper coverage
#56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm this issue on vue-enterprise-boilerplate. I've also noticed tests that should pass sometimes failing unless I clear the cache. If there's some information I can collect the next time it happens, I'm happy to post it here. |
Any info is usefu:
Also, you could delete this line and see if it solves the issue—https://github.com/vuejs/vue-jest/blob/master/vue-jest.js#L6. |
I also just confirmed that deleting that line fixes the issue, so it does seem to be cache-related. |
Does anyone have an example of a test that fails currently if the cache isn't cleared? I'd like to add a test case to the library when I fix the issue |
The best solution right now might be to remove the getCacheKey function. The |
I don't have an example of a test that fails, as it's not a persistent problem. At some point, a test will start failing when it shouldn't and I'm not sure what the trigger is. Then I clear the cache and it's all good. The coverage problem is very reproducible though. On vue-enterprise-boilerplate, running |
I'm unable to reproduce. I cloned the vue-enterprise-boilerplate (which is great by the way 😀), ran
Results:
I think the solution is to remove the getCacheKey method temporarily. |
So weird! I'm not sure if this is another option, but it looks like Facebook offers a (And as an aside about the boilerplate, please don't hesitate to let me know if you have any suggestions/questions about how I'm managing unit tests there, including the global helpers in |
Thanks @chrisvfritz , I wasn't aware of that method. Would you be able to use it on this line—https://github.com/vuejs/vue-jest/blob/master/vue-jest.js#L6- and see if it fixes the issue. I'm still unable to reproduce the bug locally |
Definitely! It looks like we need a list of files whose content can be used as a key. What do you recommend we use in our case? |
Sorry, I didn't see this message! I've removed cacheing as a temporary fix in 2.1.1. I believe we just use the filename, and then set getCacheKey to createCacheKeyFunction. It should be called with the correct arguments |
I've been running |
Same issue here, |
After creating a project using |
I've also encountered @chrisvfritz 's issue with tests failing until the cache is cleared or jest is called with no-cache. Other people here are also encountering it on the same tests. |
I also recently had this issue which was causing none of the |
I can confirm this issue still exists on |
This issue came out of nowhere for me, took me way too long to recognize that it's a cache error. FIXAll tests work again with adding
SETUP
ERRORHere is the error from console:
TEST
Even the most simple
..but again, other tests fail, too. |
"test:unit": "vue-cli-service test:unit --no-cache" worked for me!! |
This one is a little frustrating for me. Using
|
@Jack-Barry I'm experiencing the exact same issue, did you find a workaround? |
@couellet For me it was a matter of giving up on keeping my TypeScript in a separate file, and might have also been partly due to pulling in updated dependencies. If I put my business logic between the Not a huge deal for our project, just was hoping to keep the business logic in a proper |
@Jack-Barry We're using the same setup, with the |
I have the same problem with
|
It seems that running unit tests can result in failures if the build is not run on a clean machine, examples of this can be found at: - https://buildkite.com/authelia/authelia/builds/1083#8916f6fc-6a53-4619-8c2e-a762f78f1de2 - https://buildkite.com/authelia/authelia/builds/1095#2206e39c-55dd-4311-8348-09f4f7c90fa1 This seems to be a pretty common issue too, just google issues with jest cache: - vuejs/vue-jest#56
It seems that running unit tests can result in failures if the build is not run on a clean machine, examples of this can be found at: - https://buildkite.com/authelia/authelia/builds/1083#8916f6fc-6a53-4619-8c2e-a762f78f1de2 - https://buildkite.com/authelia/authelia/builds/1095#2206e39c-55dd-4311-8348-09f4f7c90fa1 This seems to be a pretty common issue too, just google issues with jest cache: - vuejs/vue-jest#56
For others struggling with the cache not being cleared during package.json
|
Is this issue linked to code coverage reporting import statements as uncovered lines? I'm encountering this with a vue/gridsome project. jest: 26.6.3 no cache doesn't seem to help, this is my jest config:
|
I think the source map is incorrect, which results in the incorrect coverage... |
I have been digging into why many of our well tested components/views are not showing up on coverage reports, and I noticed that if I applied the
--no-cache
flag to jest I started getting appropriate coverage numbers. There seems to be an issue with thevue-jest
caching mechanism that may be preventing some from getting appropriate coverage numbers.We copied our settings from https://github.com/eddyerburgh/vue-test-utils-jest-example
The text was updated successfully, but these errors were encountered: