-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Jest 25's change in behaviour of collectCoverageFrom option #9464
Comments
We ran into this as well. Jest 25 moved up to micromatch 4 which is where the problem seems to be: micromatch/micromatch#179. This is the workaround we are using for now: micromatch/micromatch#179 (comment) |
Oh, this is very interesting! Thanks for that link @joelpalmer. Could you share which pattern you changed and to what? |
Sure @SimenB - that workaround comment is actually from us: micromatch/micromatch#179 (comment) But, to add a little more context, in collectCoverage: true,
collectCoverageFrom: [
'**/*.js',
- '!(coverage|config|scripts|tests)/**'
+ '!**/(coverage|config|scripts|tests)/**'
],
coverageReporters: ['html', 'lcovonly', 'text-summary'],
testEnvironment: 'node', |
@joelpalmer thanks for the detail. I maintain micromatch, I'm looking into this. |
I can confirm that joelpalmer solution works fine. I went through the same change of behavior but that did it. |
Upgrading to Jest 25.2.4 has resolved this issue for us! We didn't have to make any changes to our |
For me, the original issue is still occurring in 25.2.4. Even though I specified:
to be ignored, I'm still seeing directories from |
I don't think we've changed anything to address this. I don't really think we can work around it either, without downgrading micromatch which we really don't wanna do (it'd be a breaking change as well) |
Sorry for the radio silence on this. I’ll try to get this resolved in micromatch ASAP.
…Sent from my iPhone
On Mar 31, 2020, at 5:44 PM, Simen Bekkhus ***@***.***> wrote:
I don't think we've changed anything to address this. I don't really think we can work around it either, without downgrading micromatch which we really don't wanna do (it'd be a breaking change as well)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@jonschlinkert are there any news on this issue on the micromatch side? |
Summary: Update `jest` to the latest version. This will allow for creating coverage report files as needed, which is not supported with current version. Note that the `collectCoverageFrom` regex exclusion has been removed. It was not matching any file and is very likely broken: jestjs/jest#9464, so it's better to no rely on it. The coverage behavior seems to change quite a lot, because it takes into acount the files with 0 coverage which were previously not accounted for. Test Plan: npm install npm test npm run test:coverage Reviewers: #bitcoin_abc, deadalnix, majcosta Reviewed By: #bitcoin_abc, deadalnix, majcosta Subscribers: josephroyking, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8828
@csvan This should have been fixed in micromatch 4.0.4, can someone confirm if issue goes away after the upgrade? |
micromatch/micromatch#179 (comment) With such settings
I still see Could anyone please check if new micromatch will work for them? |
For people seeing improvements from rolling back micromatch, please see #11293 |
To sum it up.
collectCoverageFrom: [
'!**/__mocks__/**',
'!**/__tests__/**',
'extension/**'
], What this basically means is
Because the order matters the last glob is simply overwriting the two negations, so in the end the config simply means
To fix the behaviour ensure that the order of globs does make sense for your case. In the example it would mean moving the negated patterns to the end of the array:
|
Thanks for clarifying here @danez! As you say, this change of behaviour is correct (albeit somewhat unexpected as it is not mentioned in Micromatch's changelog). So I think we can close this 🙂
It's available in |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
💥 Regression Report
After upgrading from Jest 24 to Jest 25 we are seeing more files in our coverage reports that we used to have. It seems like the behaviour of the
collectCoverageFrom
glob patterns has changed.Last working version
Worked up to version: 24.9.0
Stopped working in version: 25.1.0
To Reproduce
Our folder structure is the following:
client/
extension/
chrome/
js/
__tests__/
Our
jest.config.js
has the following option:Expected behavior
The expectation is that coverage is collected from
module.js
but NOT fromsome_file.js
. In Jest 24 this is the case, but in Jest 25 coverage is being collected fromsome_file.js
even though we've set'!**/__tests__/**',
.To work around this, we had to explicitly add
'!extension/chrome/js/__tests__/**'
to the list of directories and that made Jest 25 ignore it.Link to repl or repo (highly encouraged)
Hopefully the details above are enough. If not, I can help setup a test repo to reproduce.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: