I can't get the coverage anymore with Jest 24.
Steps to reproduce the behavior:
This is my jest configuration:
{
"verbose": true,
"clearMocks": true,
"restoreMocks": true,
"setupFilesAfterEnv": [
"
],
"collectCoverage": true,
"collectCoverageFrom": [
"/.{js}",
"!/node_modules/",
"!index.js",
"!config/",
"!coverage/",
"!webpack.dev.config.js",
"!client/index.js",
"!client/store/",
"!client/reducers/",
"!client/sagas/",
"!client/style/"
],
"testMatch": [
"/__tests__/?(.)(spec|test).js"
],
"moduleNameMapper": {
"\.(scss)$": "
},
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
I suppose it should still work as per documentation.
testMatch is likely invalid. Can you use default one and check again? (just delete it from config)
Ahh, I don't know why, but copy/paste didn't work.
"testMatch": [
"*/__tests__/?(.)(spec|test).js"
],
This is how it is. And it's valid, because my tests are passing, but the coverage is not there.
PS I removed it just for test, same result.
"**/*.{js}", looks iffy to me (try just "**/*.js").
Anyways, please put together a reproduction like the template asked you to. Just config isn't enough
Pff, thanks man. This syntax worked in v23.
Yes, it's still an invalid glob. This is mentioned at the top of the list of breaking changes in the blog post: https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#breaking-changes
Great you got it working, though!
Thanks for you help, Simen!
Can also change to '**/*.{js,}' if you want to keep the same curly-brace syntax, but only one file extension.
This comment worked: https://github.com/facebook/jest/issues/7865#issuecomment-462389513 馃憤 Thanks
@maneetgoyal The comment did not work for me, sadly. I have created another issue for this problem here.
@JimTheMan In my case, I was also missing the moduleFileExtensions property and was using .ts files instead.
So, the Jest (v. 24.9.0) config eventually had these properties:
// An array of file extensions your modules use
moduleFileExtensions: ["ts", "js"],
// Needed to collect coverage data
collectCoverage: true,
// Needed to specify from where to collect the coverage data
collectCoverageFrom: ["./src/**/*.ts"],
// "text" reporter logs the coverage report in the console
coverageReporters: ["text", "html"],
// Stores coverage report in this directory
coverageDirectory: "./coverage"
Hope it helps a bit.
Most helpful comment
"**/*.{js}",looks iffy to me (try just"**/*.js").Anyways, please put together a reproduction like the template asked you to. Just config isn't enough