https://cypress.io logo
@cypress/code-coverage : can't exclude *cy.ts from...
# i-need-help
b
I'm trying to collect the code coverage from
*.cy.ts
with
@cypress/code-coverage
and
Istanbul
. The problem is that I can't exclude the
*.cy.ts
files from coverage report. Here is my configuration : package.json :
Copy code
"devDependencies": {
    ...
    "@cypress/code-coverage": "3.10.0",
    "@istanbuljs/nyc-config-typescript": "1.0.2",
    "cypress": "12.4.1",
    "vite-plugin-istanbul": "4.0.0",
    ...
  },
cypress.config.ts :
Copy code
import { defineConfig } from 'cypress'
import registerCodeCoverageTasks from '@cypress/code-coverage/task'

export default defineConfig({
  env: {
    codeCoverage: {
      exclude: ['cypress/**/*.*', 'src/**/*.cy.ts'],
    },
  },
  component: {
    devServer: {
      framework: 'vue',
      bundler: 'vite',
    },
    setupNodeEvents(on, config) {
      registerCodeCoverageTasks(on, config)

      return config
    },
  },
})
.nycrc.json :
Copy code
{
  "all": true,
  "extends": "@istanbuljs/nyc-config-typescript",
  "check-coverage": true,
  "include": [
    "src/**/*.ts",
    "src/**/*.vue"
  ],
  "exclude": [
    "src/**/*.cy.ts",
    "cypress/**/*.*",
    "**/*.d.ts",
    "**/*.cy.ts"
  ],
  "report-dir": "./coverage-cypress"
}
Anything I'm missing ? Thanks for your help !
It seems to work today, without any changes on my configuration...
2 Views