cypress-io / cypress-io/code-coverage
Do not generate a coverage report when visiting local HTML files with `expectBackendCoverageOnly` enabled
- Dominant language
- TypeScript
- Stars
- 445
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Description
Problem:
When visiting a local HTML file (cypress/downloads/test.html), the coverage report is not generated. However, when visiting an external URL like https://docs.cypress.io/app/tooling/code-coverage, the coverage report is successfully generated.
and the error message is `code-coverage/test-apps/backend/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application?`
Cypress Configuration:
```js
const { defineConfig } = require('cypress')
module.exports = defineConfig({
fixturesFolder: false,
env: {
codeCoverage: {
url: 'http://localhost:3003/__coverage__',
expectBackendCoverageOnly: true
},
},
e2e: {
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:3003',
},
})
```
Test Spec:
```js
///
context('Converage Test', () => {
it('backend test', function() {
cy.visit('/')
cy.request('/hello')
})
it('visit local html file', {baseUrl: null}, () => {
cy.visit('cypress/downloads/test.html') // failed to generate coverage report
// cy.visit('https://docs.cypress.io/app/tooling/code-coverage') //Successfully generated the coverage report.
})
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.