{"id":13047,"library":"cypress-skip-this-test","title":"Cypress Skip This Test","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/bahmutov/cypress-skip-this-test","tags":["javascript","cypress","cypress-plugin"],"install":[{"cmd":"npm install cypress-skip-this-test","lang":"bash","label":"npm"},{"cmd":"yarn add cypress-skip-this-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add cypress-skip-this-test","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a named export, primarily intended for ES module usage in Cypress spec files. CommonJS `require` is not officially supported or tested, and may not work as expected in a modern Cypress setup.","wrong":"const skipIfPreviousTestsFailed = require('cypress-skip-this-test')","symbol":"skipIfPreviousTestsFailed","correct":"import { skipIfPreviousTestsFailed } from 'cypress-skip-this-test'"}],"quickstart":{"code":"import { skipIfPreviousTestsFailed } from 'cypress-skip-this-test'\n\ndescribe('Parent suite', () => {\n  // second test fails on purpose\n  // and the third test should skip\n  beforeEach(skipIfPreviousTestsFailed)\n\n  it('test 1', () => {\n    cy.log('Test 1 runs')\n    expect(true).to.be.true\n  })\n\n  it('test 2', () => {\n    cy.log('Test 2 runs and fails')\n    throw new Error('fail on purpose')\n  })\n\n  it('test 3', () => {\n    cy.log('Test 3 should be skipped')\n    expect(true).to.be.true // This assertion should not be reached\n  })\n})","lang":"javascript","description":"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."},"warnings":[{"fix":"Apply `beforeEach(skipIfPreviousTestsFailed)` within every `describe` block where you need tests to be skipped based on prior failures in that specific suite.","message":"The `skipIfPreviousTestsFailed` hook operates per `describe` block. If your tests are structured with nested `describe` blocks or across multiple top-level suites, you must apply `beforeEach(skipIfPreviousTestsFailed)` within each relevant `describe` block where this skipping behavior is desired. It does not automatically propagate to child or sibling suites without explicit application.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"This plugin is designed for scenarios where tests have explicit sequential dependencies. If your tests are truly independent or their order of execution is not critical, applying this plugin might inadvertently mask failures or make debugging harder by skipping tests that could have provided valuable insights, even if a previous test failed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"When tests are skipped using Mocha's `this.skip()` (which this plugin leverages internally), `afterEach` hooks for the skipped tests might also be skipped or behave unexpectedly depending on the Cypress runner and environment (headed vs. headless).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you pass the function reference: `beforeEach(skipIfPreviousTestsFailed)` instead of `beforeEach(skipIfPreviousTestsFailed())`.","cause":"The `skipIfPreviousTestsFailed` function was invoked immediately with `()` instead of being passed as a function reference to `beforeEach`.","error":"TypeError: Cannot read properties of undefined (reading 'call') or similar when invoking `beforeEach`"},{"fix":"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.","cause":"The `beforeEach(skipIfPreviousTestsFailed)` hook was not placed in the correct `describe` block scope, or `testIsolation` is set to `true` (the Cypress default) which resets the browser state for each test, making the plugin's state tracking ineffective.","error":"Tests are not being skipped as expected, even after a previous test failed in the suite."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}