Skip to content

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

Open
@kingconan

Description

@kingconan

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.
  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions