You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
example/unit-tests-ts is not producing coverage for unit-test files #435
Describe the bug
We are looking hard to make the cypress test-coverage for unit-tests for functionality written in TS and after trying the example/unit-tests-ts in this repo, we see that this example is still not working. Can someone work on this and make it work?
@bahmutov Can u please provide a solution to this issue? Of all the work we did to replace testing framework from Jest and Selenium to Cypress last year, this is the only limitation we are stuck now. Thanks.
I was able to get this working by using webpack instead of browserify and I also included and got it working in my next.js project. Hopefully this might be useful for someone else.
I also managed to get this working with webpack, with a similar configuration to the one above, but I've noticed that it produces warnings in the browser, such as
even though there's no "after each" hook in my test spec.
The "after each" hook appears to come from @cypress/code-coverage (@3.9.10 in this case).
@emiljohansson with your nextjs app you can better use babel.config.js else your production app ends up with istanbul wrappers :) Just pass a NODE_ENV test when executing your script, hope it helps!
use-babelrc only compiled .js/.jsx files and couldn't resolve .ts imports, so TypeScript specs failed to bundle and .ts sources weren't instrumented. It now compiles .ts/.tsx with your .babelrc. Add @babel/preset-typescript (and a JSX preset such as @babel/preset-react for .tsx):
Activity
aslamj commentedon May 19, 2021
@bahmutov Can u please provide a solution to this issue? Of all the work we did to replace testing framework from Jest and Selenium to Cypress last year, this is the only limitation we are stuck now. Thanks.
Markkop commentedon Jun 15, 2021
Same here, can't find the root of the problem.
emiljohansson commentedon Jul 23, 2021
I was able to get this working by using webpack instead of browserify and I also included and got it working in my next.js project. Hopefully this might be useful for someone else.
This ticket might be related: #361
I also cleared the presets in the babel config.
jashworth commentedon Sep 4, 2021
I also managed to get this working with webpack, with a similar configuration to the one above, but I've noticed that it produces warnings in the browser, such as
even though there's no "after each" hook in my test spec.
The "after each" hook appears to come from @cypress/code-coverage (@3.9.10 in this case).
maapteh commentedon Sep 20, 2021
@emiljohansson with your nextjs app you can better use babel.config.js else your production app ends up with istanbul wrappers :) Just pass a NODE_ENV test when executing your script, hope it helps!
chore: tidy use-babelrc types, test cleanup, and .tsx docs
github-actions commentedon Nov 2, 2026
🎉 This issue has been resolved in version 4.1.3 🎉
The release is available on:
Your semantic-release bot 📦🚀
jennifer-shehane commentedon Nov 2, 2026
Fixed in #1013.
use-babelrconly compiled.js/.jsxfiles and couldn't resolve.tsimports, so TypeScript specs failed to bundle and.tssources weren't instrumented. It now compiles.ts/.tsxwith your.babelrc. Add@babel/preset-typescript(and a JSX preset such as@babel/preset-reactfor.tsx):{ "presets": ["@babel/preset-typescript"], "plugins": ["istanbul"] }Working example:
test-apps/unit-tests-ts. It runs in CI.If coverage is still missing after upgrading, open a new issue with your Cypress and plugin versions, your
.babelrc, and a minimal reproduction.