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

Do not generate a coverage report when visiting local HTML files with expectBackendCoverageOnly enabled #906

Open
kingconan opened this issue Nov 26, 2024 · 0 comments

Comments

@kingconan
Copy link

kingconan commented Nov 26, 2024

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:

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:

/// <reference types="Cypress" />

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.
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant