The `cypress-skip-this-test` package provides a utility to automatically skip subsequent tests within a Cypress test suite if any preceding test in that suite has failed. This is particularly useful for end-to-end test scenarios where tests are interdependent, preventing unnecessary runs of tests that rely on a previously failed setup step. The current stable version is `1.0.1`, released recently in September 2024. As a new package, its release cadence is still establishing, but it indicates active maintenance. Its key differentiator is simplifying the management of interdependent tests in Cypress by automating test skipping through a `beforeEach` hook, addressing a common pain point in E2E testing where manual skipping or cleanup can be cumbersome. It offers a concise, declarative way to manage test execution flow based on preceding test outcomes.
npm install cypress-skip-this-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and apply `skipIfPreviousTestsFailed` as a `beforeEach` hook within a `describe` block. If 'test 2' fails, 'test 3' will be automatically skipped, illustrating the plugin's core functionality for managing interdependent tests.
Apply `beforeEach(skipIfPreviousTestsFailed)` within every `describe` block where you need tests to be skipped based on prior failures in that specific suite.
Carefully consider your test structure and dependencies. Only apply `cypress-skip-this-test` to suites where a failure in an earlier test legitimately renders subsequent tests invalid or redundant. For independent tests, rely on Cypress's default behavior.
Be mindful of cleanup logic in `afterEach` hooks within suites using this plugin. If critical cleanup is needed regardless of test skipping, consider moving it to `after` hooks or ensuring `afterEach` hooks are resilient to the state of a skipped test.
Ensure you pass the function reference: `beforeEach(skipIfPreviousTestsFailed)` instead of `beforeEach(skipIfPreviousTestsFailed())`.
Ensure `beforeEach(skipIfPreviousTestsFailed)` is placed directly within the `describe` block containing the interdependent tests. Also, consider setting `testIsolation: false` in your Cypress configuration (`cypress.config.js`) for the spec files using this plugin, as it relies on state persistence across tests in the same suite. Note that disabling `testIsolation` has other implications for test independence.
No dependency data recorded yet.