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

feat: Skip test coverage #643

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

littleapple27
Copy link

@littleapple27 littleapple27 commented Apr 13, 2023

This merge request allows skipping the hooks to generate code coverage reports by using the test config object.

Problem Statement:

I had a test that was consistently failing due to the node process that writes the coverage reports in the afterEach hook causing the pipeline to fail, possibly due to too much memory. I am unable to upgrade to Cypress 12 to test if the memory enhancements included would solve my issue in the pipeline. I was in search of a solution that would 1) generate a code coverage report, 2) exclude this particular test from the code coverage reporting, and 3) have the test continue alongside the other tests that were passing in the pipeline and collecting code coverage successfully.

By combining the solution described here: https://glebbahmutov.com/blog/skip-before-each-hook/ I was able to successfully meet my solution goals as described above. I was able to get a passing pipeline, collect code coverage for all other tests, and exclude the problematic test from the code coverage report thereby eliminating the pipeline failure.

Feature Request:

I am requesting a feature to be added to the package that will enable skipping code coverage collection per test file. Allow passing {skipTestCoverage: true} in order to stop the execution of the code-coverage hooks in all stages (before, beforeEach, after, afterEach) for a single test file. This particular feature may also be of value in other ways, allowing not only the exclusion of instrumented files but also test files from test coverage reports proving more accurate results.

describe('excludes test from code coverage reporting', {skipTestCoverage: true}, () => {
  it(
    'test expects 1 to equal 1',
    { skipTestCoverage: true },
    () => {
      expect(1).to.equal(1)
    },
  )
})

@CLAassistant
Copy link

CLAassistant commented Apr 13, 2023

CLA assistant check
All committers have signed the CLA.

@littleapple27 littleapple27 marked this pull request as ready for review April 13, 2023 17:46
@nagash77 nagash77 added the type: enhancement New feature or request label Apr 13, 2023
@littleapple27
Copy link
Author

Hello, curious if this is in consideration as an enhancement to the package and the next steps, if any.

@jennifer-shehane jennifer-shehane changed the title Skip test coverage feat: Skip test coverage Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants