-
Notifications
You must be signed in to change notification settings - Fork 78
Cove coverage isn’t working for TS and Cra-v3 #258
Comments
|
It is weird, and that project has code coverage by default https://github.com/bahmutov/try-cra-app-typescript#code-coverage At least on Mac and Linux it works, I even added a check on CI. Could you run that project with verbose debug logs as described and see if there is an obvious error somewhere? Or paste the logs somewhere? |
See how it is searching through
Can I ask you to run one more time, and enable just
This will print the entire webpack config so we can see why this check does not find the Babel loader that is supposed to be there debug('looking through oneOf rules')
const babelRule = oneOfRule.oneOf.find(
(rule) => rule.loader && rule.loader.includes('/babel-loader/'),
)
return babelRule Should be something like this |
Hmm, somehow it does not print the full module object, so I don't see the inside of the ok, can you edit your local Instead of this function const findBabelRule = (webpackOptions) => {
if (!webpackOptions) {
return
}
if (!webpackOptions.module) {
return
}
debug('webpackOptions.module %o', webpackOptions.module)
if (!Array.isArray(webpackOptions.module.rules)) {
return
}
const oneOfRule = webpackOptions.module.rules.find((rule) =>
Array.isArray(rule.oneOf),
)
if (!oneOfRule) {
debug('could not find oneOfRule')
return
}
debug('looking through oneOf rules')
const babelRule = oneOfRule.oneOf.find(
(rule) => rule.loader && rule.loader.includes('/babel-loader/'),
)
return babelRule
} overwrite it to const findBabelRule = (webpackOptions) => {
if (!webpackOptions) {
return
}
if (!webpackOptions.module) {
return
}
debug('webpackOptions.module %o', webpackOptions.module)
if (!Array.isArray(webpackOptions.module.rules)) {
return
}
const oneOfRule = webpackOptions.module.rules.find((rule) =>
Array.isArray(rule.oneOf),
)
if (!oneOfRule) {
debug('could not find oneOfRule')
return
}
debug('looking through oneOf rules')
debug('oneOfRule.oneOf %o', oneOfRule.oneOf)
oneOfRule.oneOf.forEach(rule => debug('rule %o', rule))
const babelRule = oneOfRule.oneOf.find(
(rule) => rule.loader && rule.loader.includes('/babel-loader/'),
)
return babelRule
} |
Uggh, I see the problem now - the check uses forward slashes!!! OMG, what a rookie mistake - thank you so much for patiently debugging this |
Merging the fix in #259 |
@bahmutov thank you too, for so quick respond and fix. I can confirm that it's working now for me! |
should be fixed in version v4.3.1 |
We have been created our React app (components library for storyBook) with cra-v3. Currently we are using TypeScript, and our components are in .tsx files. We don’t have any webpack or babel file to modify it. I already checked all your examples but have never seen something working for typescript and cypress unit testing where code coverage is collecting without going to some url. As a result I’m getting an empty nyc_out file.
If it's possible to do, please, add here - https://github.com/bahmutov/try-cra-app-typescript
P.S. we are migrating to cypress from jest + enzyme. And for jest coverage is working for same project.(same Istanbul tool)
Tools:
Cypress 4.7.0
Cypress-react-unit-test 4.3.0
Os: Windows 10
The text was updated successfully, but these errors were encountered: