Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.