Skip to content
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

support.js throws an error on "const applicationSourceCoverage = win?.__coverage__. #866

Closed
krishollenbeck opened this issue Aug 16, 2024 · 2 comments · Fixed by #881
Closed
Labels

Comments

@krishollenbeck
Copy link

krishollenbeck commented Aug 16, 2024

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.
image

Versions

  • What is this plugin's version? If this is NOT the latest released version, can you try the latest version, please?

"@cypress/code-coverage": "3.12.45",

  • If the plugin worked before in version X but stopped after upgrading to version Y, please try the released versions between X and Y to see where the breaking change was.
    Appears to be working before this change. 1cf7df2
    Version 3.12.32

  • What is the Cypress version?
    "cypress": "12.14.0",

  • What is your operating system?
    Windows 11

  • What is the shell?
    N/A

  • What is the Node version?
    18.19.1

  • What is the NPM version?
    10.2.4

  • How do you instrument your application? Cypress does not instrument web application code, so you must do it yourself.
    I am using nyc

  • When running tests, if you open the web application in a regular browser and open DevTools, do you see window.__coverage__ object? Can you paste a screenshot?
    Tests fail to run because of the error. But I see window.__coverage__ when running my server outside of cypress.

image
  • Is there a .nyc_output folder? Is there a .nyc_output/out.json file? Is it empty? Can you paste at least part of it so we can see the keys and file paths?
    There is no output folder. Error prevents tests from running.

  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files?
    No

  • Do you run Cypress tests in a Docker container?
    No

Describe the bug
support.js throws an error on const applicationSourceCoverage = win?.__coverage__. I am using a custom webpack loader. So this could simply be an issue with @jsdevtools/coverage-istanbul-loader not understanding how to handle "optional chaining operators". But I could be wrong. Webpack loaders are sort of new to me. Possibly I just need to use something besides @jsdevtools/coverage-istanbul-loader?

Also, I found this same issue reported on stackoverflow.
https://stackoverflow.com/questions/78483412/cypress-code-coverage-unexpected-token-win-coverage/78880561#78880561

coverage.webpack.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|ts)$/,
        loader: '@jsdevtools/coverage-istanbul-loader',
        options: { esModules: true },
        enforce: 'post',
        include: require('path').join(__dirname, '..', 'src'),
        exclude: [
          /\.(e2e|spec)\.ts$/,
          /node_modules/,
          /(ngfactory|ngstyle)\.js/
        ]
      }
    ]
  }
};

Link to the repo
I currently have no repo. This is currently setup on an internal project. I can maybe make a repo if necessary.

@krishollenbeck
Copy link
Author

Ran into a similar issue in Cypress today. I'm thinking this could be an issue with Cypress. While investigating further. I came across these issues.

cypress-io/cypress#20753
cypress-io/cypress#16914

@cypress-app-bot
Copy link

🎉 This issue has been resolved in version 3.13.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants