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

cypress e2e can not generate coverage report #17587

Closed
1 of 4 tasks
nnsay opened this issue Jun 14, 2023 · 3 comments
Closed
1 of 4 tasks

cypress e2e can not generate coverage report #17587

nnsay opened this issue Jun 14, 2023 · 3 comments
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@nnsay
Copy link

nnsay commented Jun 14, 2023

Current Behavior

cypress e2e test can generate the coverage report files

Expected Behavior

cypress e2e test can not generate the coverage report files

GitHub Repo

https://github.com/nnsay/nx-example

Steps to Reproduce

git clone https://github.com/nnsay/nx-example

yarn install

yarn nx run tools:e2e

I add the e2e in the existing Nx project which name is tools.

Nx Report

Node   : 16.20.0
   OS     : darwin arm64
   yarn   : 1.22.19
   Hasher : Native
   
   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/cypress        : 16.3.2
   @nx/devkit         : 16.3.2
   @nx/esbuild        : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nx/node           : 16.3.2
   @nx/storybook      : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/vite           : 16.3.2
   typescript         : 5.0.4
   ---------------------------------------
   Local workspace plugins:
         @nnsay/tools

Failure Logs

> nx run tools:e2e  [existing outputs match the cache, left as is]

info => Starting manager..
╭────────────────────────────────────────────────╮
│                                                │
│   Storybook 7.0.20 for react-vite started      │
│   99 ms for manager and 3.65 s for preview     │
│                                                │
│    Local:            http://localhost:4400/    │
│    On your network:  http://localhost:4400/    │
│                                                │
╰────────────────────────────────────────────────╯
[17562:0614/154045.352800:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:58720/devtools/browser/5b992623-7737-4baf-ad90-4743dba6d284
{
  videosFolder: '../../dist/cypress/libs/tools/videos',
  screenshotsFolder: '../../dist/cypress/libs/tools/screenshots',
  video: true,
  chromeWebSecurity: false,
  fileServerFolder: '.',
  supportFile: 'cypress/support/e2e.ts',
  specPattern: 'cypress/**/*.cy.{js,jsx,ts,tsx}',
  fixturesFolder: 'cypress/fixtures'
}
{
  videosFolder: '../../dist/cypress/libs/tools/videos',
  screenshotsFolder: '../../dist/cypress/libs/tools/screenshots',
  video: true,
  chromeWebSecurity: false,
  fileServerFolder: '.',
  supportFile: 'src/support/e2e.ts',
  specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
  fixturesFolder: 'src/fixtures',
  baseUrl: 'http://localhost:4400'
}

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.14.0                                                                        │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v16.20.0 (/Users/wangjian/.volta/tools/image/node/16.20.0/bin/node)            │
  │ Specs:          1 found (app.cy.ts)                                                            │
  │ Searched:       cypress/**/*.cy.{js,jsx,ts,tsx}                                                │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  app.cy.ts                                                                       (1 of 1)


  albedo-drawer
Cannot find coverage file /Users/wangjian/github/nnsay/nnsay/libs/tools/.nyc_output/out.json
Skipping coverage report
    ✓ basic (3382ms)


  1 passing (3s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     3 seconds                                                                        │
  │ Spec Ran:     app.cy.ts                                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started compressing: Compressing to 32 CRF                                                     
  -  Finished compressing: 0 seconds                                                 

  -  Video output: /Users/xxx/github/nnsay/nnsay/dist/cypress/libs/tools/videos/app.cy.ts.mp4


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  app.cy.ts                                00:03        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:03        1        1        -        -        -  


 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target e2e for project tools (14ms)
 
   Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
 
✨  Done in 0.47s.

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@mandarini mandarini added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Jun 14, 2023
@Coly010
Copy link
Contributor

Coly010 commented Jun 15, 2023

Hey there! :)

There are two problems with your current setup.

  1. As stated in the Cypress Documentation, you need instrument your code yourself for the code coverage to take effect: https://docs.cypress.io/guides/tooling/code-coverage#Instrumenting-code

  2. You use vite to build your cypress and storybook setup. Using istanbul to instrument your code with vite requires using vite-istanbul-plugin but there's an open issue on that plugin with compatibility with nx repos: window__coverage__ is undefined on nx workspace iFaxity/vite-plugin-istanbul#94

Unfortunately, these are tools that we do not control and the issues lie outside the scope of Nx. Therefore, I'm going to close this issue.

You should raise an issue on the cypress repo and follow along with the issue listed above for vite-istanbul-plugin.

@Coly010 Coly010 closed this as completed Jun 15, 2023
@nnsay
Copy link
Author

nnsay commented Jun 16, 2023

Trace the reason at: cypress-io/code-coverage#657

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants