-
Notifications
You must be signed in to change notification settings - Fork 109
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
.nyc_output/out.json
is an empty object when using with @cypress/react
#472
Comments
Related issues that I've tried out for the last few days but without success: To give context on the actual project where I first encountered the bug:
I don't fully understand why code coverage is not working, but some suspicions I have if they are helpful for the debugger:
Thank you guys for the great work, and let me know if you need any other information if the repro repo is insufficient. |
Hi Chris, saw your comment. I had a look at your code base and wonder if you might be missing Just a hunch - let me know how you go. |
Hi @twhoff appreciate you taking the time to help here! 🤗 I have |
Hello @chrisrzhou, hello all, here is my solution, which from my point of view is a gap in the documentation. In my case when using the new component tests, which was mentioned in the context of the question ( The reason was that, according to the documentation, I put the line there, then it works as well, because cypress can register the tasks in component tests. |
Hey @namespace-github, thank you so much for getting back to me. I tried your solution and it does not seem to work. I might be missing something still and the online documentations have not been too helpful so really looking forward to your solution. In my repro repo, I added in chrisrzhou/cypress-code-coverage-issue-472@f6e496d, a commit that adds If you have any insights or can reproduce a fix by cloning the repro repo, that would be sweet! |
Is there any update on this issue ? I am facing the same issue. While running the application using dev server on regular browser, I see |
Same here as @VaibhavP17 said… |
Same... |
Same here |
I have been struggling with an empty object in my My code was correctly instrumented by istambul, and the Cypress code-coverage plugin was correctly set up as per the docs. I had an exclusion glob pattern in my Cypress config file, like this: export default defineConfig({
e2e: {
specPattern: [
'**/*.feature',
'!**/ignored/**/*.feature',
],
},
}) It turns out that
TL;DR |
Logs and screenshots
Please provide debug logs by running Cypress from the terminal with
DEBUG=code-coverage
environment variable set, see the Debugging section of the README file.Debug logs
Versions
package.json
in repo for more details).window.__coverage__
object? Following the official docs, I can seewindow.__coverage__
object for the files that the test is touching..nyc_output
folder? Is there.nyc_output/out.json
file. Is it empty? Both folder and file exists, the contents is just the empty object{}
.package.json
(nyc
object) or in other NYC config files NoDescribe the bug
Bug Report
Repro Link
https://github.com/chrisrzhou/cypress-code-coverage-issue-472
Context
It is a minimal example with the following requirements:
"type": "module"
is explicitly marked in thepackage.json
.cjs
in order for the tests to run.In
cypress/plugins/index.cjs
and fields incypress.json
.@cypress/react
and usingopen-ct
andrun-ct
test runners).@cypress/code-coverage
andbabel-plugin-istanbul
based on the official docs for instrumentation).The requirements above are needed in the actual bug faced in the project, so the repo is capturing the minimal configuration of reproducing the same bug.
Reproduce
The test runner runs fine, and tests the code correctly.
Expected Behavior
Code coverage to output something meaningful in
.nyc_output/out.json
Actual Behavior
.nyc_output/out.json
is an empty object. The test runner complains that the code is not instrumented.The text was updated successfully, but these errors were encountered: