Skip to content

Coverage report appears before end of Cypress output? #465

Closed

Description

@bgoosmanviz

Logs and screenshots
Here is what I mean. "removeNodeById" is the last test in my single test file. As you can see, Cypress is correctly using the coverage:report script I defined in package.json. However, it is printing the coverage in the middle of my test results, which isn't blocking but is mildly annoying.

  ...
    1) addNode adds a node
...

> ...@1.0.41 coverage:report /Users/admin/.../api
> nyc report

-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |     100 |      100 |     100 |     100 |                   
 addNodes.ts       |     100 |      100 |     100 |     100 |                   
...                 
-------------------|---------|----------|---------|---------|-------------------
    ✓ removeNodeById removes a node (115ms)


  4 passing (12s)
  1 failing
...

Versions

  • What is this plugin's version? ^3.9.6
  • What is Cypress version? ^7.5.0
  • What is your operating system? MacOS
  • What is the shell? zsh
  • What is the Node version? v12.13.0
  • What is the NPM version? 6.12.0
  • How do you instrument your application? babel-loader w/ istanbul and @babel/preset-typescript
  • When running tests, if you open the web application in regular browser, and open DevTools, do you see window.__coverage__ object? Yup, works great.
  • Is there .nyc_output folder? Is there .nyc_output/out.json file. Coverage is working.
  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files
  "nyc": {
    "extends": "@istanbuljs/nyc-config-typescript",
    "extension": [
      ".ts"
    ],
    "include": [
      "src/**/*.ts"
    ],
    "exclude": [
      "cypress/",
      "dist/",
      "src/**/*.d.ts",
      "src/**/*.spec.ts"
    ],
    "excludeAfterRemap": false,
    "checkCoverage": true,
    "all": true,
    "branches": 100,
    "functions": 100,
    "lines": 100,
    "statements": 100,
    "skipEmpty": true,
    "reporter": [
      "lcov",
      "text"
    ]
  },
  • Do you run Cypress tests in a Docker container? Nope

Describe the bug
I'm confused why the coverage is printing before the outcome of my last test.

Link to the repo
Sorry don't have this.

Activity

  1. mitchwd commented on Jun 18, 2023

    @mitchwd

    I was having this issue too. My fix was removing text-summary from the reporter block in the .nyrc config, and then adding it to my test command in package.json. The lcov and json reports are still built too.

    // .nycrc
    {
      "all": true,
      "extends": "@istanbuljs/nyc-config-typescript",
      "reporter": ["lcov", "json"],
      "include": "src/**",
      "exclude": [
        "**/__tests__/**",
        "**/.{eslint,mocha}rc.{js,cjs}",
        "**/{ava,babel,nyc}.config.{js,cjs,mjs}"
     ]
    }
    // package.json
    {
      "name": "myProject",
      "private": true,
      "version": "0.0.0",
      "type": "module",
      "scripts": {
        "dev": "node generate-api.cjs && vite",
        "build": "tsc && vite build",
        "preview": "vite preview",
        "test": "npx cypress run --component && npx nyc report --reporter=text-summary"
      }
      // ...rest of the package.json file
    }
  2. jennifer-shehane commented on Nov 2, 2026

    @jennifer-shehane
    Member

    The report is generated in an after() hook at the end of each spec, while Cypress is still printing results, so console reporters (text, text-summary) and a coverage:report script that prints can appear before the last test's result. The coverage numbers are not affected.

    Workaround: use only file reporters in the nyc config and print the summary after the run:

    {
      "nyc": {
        "reporter": ["lcov", "json"]
      },
      "scripts": {
        "test": "cypress run && nyc report --reporter=text-summary"
      }
    }

    Documented in #1009: Console reporters print mid-run. A way to skip the per-spec report is requested in #506.

  3. github-actions commented on Nov 2, 2026

    @github-actions

    🎉 This issue has been resolved in version 4.1.3 🎉

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions