{"id":16360219,"url":"https://github.com/javierbrea/cypress-fail-fast","last_synced_at":"2025-04-09T05:12:16.126Z","repository":{"id":38378430,"uuid":"316673987","full_name":"javierbrea/cypress-fail-fast","owner":"javierbrea","description":"A Cypress plugin to skip tests on first failure.","archived":false,"fork":false,"pushed_at":"2024-09-19T19:50:09.000Z","size":4394,"stargazers_count":120,"open_issues_count":14,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T04:04:50.135Z","etag":null,"topics":["abort","automated-testing","cypress","cypress-plugin","fail-fast","failure","failure-handling","plugin","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javierbrea.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-28T06:42:51.000Z","updated_at":"2025-02-17T15:41:10.000Z","dependencies_parsed_at":"2024-06-18T14:07:52.229Z","dependency_job_id":"801dcfae-8bf1-42bf-82bc-ee717e7b7f4c","html_url":"https://github.com/javierbrea/cypress-fail-fast","commit_stats":{"total_commits":409,"total_committers":4,"mean_commits":102.25,"dds":0.3838630806845966,"last_synced_commit":"0c88df331b03dda28c10e8b34188583ecb88a2c6"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javierbrea%2Fcypress-fail-fast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javierbrea%2Fcypress-fail-fast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javierbrea%2Fcypress-fail-fast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javierbrea%2Fcypress-fail-fast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javierbrea","download_url":"https://codeload.github.com/javierbrea/cypress-fail-fast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980844,"owners_count":21027808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abort","automated-testing","cypress","cypress-plugin","fail-fast","failure","failure-handling","plugin","testing","testing-tools"],"created_at":"2024-10-11T02:10:56.806Z","updated_at":"2025-04-09T05:12:16.109Z","avatar_url":"https://github.com/javierbrea.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status][build-image]][build-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url] [![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fjavierbrea%2Fcypress-fail-fast%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/javierbrea/cypress-fail-fast/main)\n\n[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com) [![Last commit][last-commit-image]][last-commit-url] [![Last release][release-image]][release-url]\n\n[![NPM downloads][npm-downloads-image]][npm-downloads-url] [![License][license-image]][license-url]\n\n# Cypress Fail Fast\n\nEnables fail fast in Cypress, skipping the rest of tests on first failure.\n\nIt can be configured to skip all remaining tests in current spec file, in current run, or even in parallel runs.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Limitations and notes](#limitations-and-notes)\n- [Configuration](#configuration)\n  * [Environment variables](#environment-variables)\n  * [Configuration by test](#configuration-by-test)\n  * [Configuration examples for usual scenarios](#configuration-examples-for-usual-scenarios)\n  * [Configuration for parallel runs](#configuration-for-parallel-runs)\n- [Usage with TypeScript](#usage-with-typescript)\n\n## Installation\n\nAdd the plugin to `devDependencies`\n\n```bash\nnpm i --save-dev cypress-fail-fast\n```\n\nNow, depending on your Cypress version, use one of the next methods:\n\n### Installation on Cypress 10 and higher\n\nInside `cypress.config.ts` file:\n\n```javascript\nimport cypressFailFast from \"cypress-fail-fast/plugin\";\n\nexport default defineConfig({\n  e2e: {\n    setupNodeEvents(on, config) {\n      cypressFailFast(on, config);\n    },\n  },\n});\n```\n\nIn case you are using JavaScript, you may explicit the file extension in some cases:\n\n```javascript\nimport cypressFailFast from \"cypress-fail-fast/plugin.js\"\n```\n\nNote: This example shows how to install the plugin for `e2e` testing type. Read [Cypress configuration docs](https://docs.cypress.io/guides/references/configuration) for further info.\n\nAt the top of your support file (usually `cypress/support/e2e.js` for `e2e` testing type)\n\n```javascript\nimport \"cypress-fail-fast\";\n```\n\n### Installation on Cypress versions lower than 10\n\nInside `cypress/plugins/index.js`:\n\n```javascript\nmodule.exports = (on, config) =\u003e {\n  require(\"cypress-fail-fast/plugin\")(on, config);\n  return config;\n};\n```\n\nAt the top of `cypress/support/index.js`:\n\n```javascript\nimport \"cypress-fail-fast\";\n```\n\nFrom now, if one test fail after its last retry, the rest of tests will be skipped:\n\n![Cypress results screenshot](docs/assets/cypress-fail-fast-screenshot.png)\n\n## Limitations and notes\n\n* All spec files will be loaded, even after entering \"skip mode\", but every tests and hooks inside them will be skipped.\n* The `spec` strategy does not work in headed mode, because for Cypress events it is like running a single spec, so all remaining tests will be skipped.\n\n## Configuration\n\n### Environment variables\n\n* __`FAIL_FAST_STRATEGY`__: `'spec'|'run'|'parallel'`\n  * If `spec`, only remaining tests in current spec file are skipped. This mode only works in \"headless\" mode.\n  * If `run`, all remaining tests in all spec files are skipped (default value).\n  * Use `parallel` to [provide your own callbacks](#configuration-for-parallel-runs) allowing to notify from one run to the others when remaining tests should be skipped.\n* __`FAIL_FAST_ENABLED`__: `boolean = true` Allows disabling the \"fail-fast\" feature globally, but it could be still enabled for specific tests or describes using [configuration by test](#configuration-by-test).\n* __`FAIL_FAST_PLUGIN`__: `boolean = true` If `false`, it disables the \"fail-fast\" feature totally, ignoring even plugin [configurations by test](#configuration-by-test).\n* __`FAIL_FAST_BAIL`__: `Number = 1` Enable the skip mode immediately upon n number of failing test suite. Defaults to 1.\n\n#### Examples\n\n```bash\nCYPRESS_FAIL_FAST_PLUGIN=false npm run cypress\n```\n\nor set the \"env\" key in the `cypress.json` configuration file:\n\n```json\n{\n  \"env\":\n  {\n    \"FAIL_FAST_STRATEGY\": \"run\",\n    \"FAIL_FAST_ENABLED\": true,\n    \"FAIL_FAST_BAIL\": 2,\n  }\n}\n```\n\n### Configuration by test\n\nIf you want to configure the plugin on a specific test, you can set this by using the `failFast` property in [test configuration](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Test-Configuration). The plugin allows next config values:\n\n* __`failFast`__: Configuration for the plugin, containing any of next properties:\n  * __`enabled`__ : Indicates wheter a failure of the current test or children tests _(if configuration is [applied to a suite](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Suite-configuration))_ should produce to skip the rest of tests or not. Note that the value defined in this property has priority over the value of the environment variable `CYPRESS_FAIL_FAST_ENABLED` _(but not over `CYPRESS_FAIL_FAST_PLUGIN`, which disables the plugin totally)_.\n\n#### Example\n\nIn the next example, tests are configured to \"fail-fast\" only in case the test with the \"sanity test\" description fails. If any of the other tests fails, \"fail-fast\" will not be applied.\n\n```js\ndescribe(\"All tests\", {\n  failFast: {\n    enabled: false, // Children tests and describes will inherit this configuration\n  },\n}, () =\u003e {\n  it(\"sanity test\", {\n    failFast: {\n      enabled: true, // Overwrite configuration defined in parents\n    },\n  }, () =\u003e {\n    // Will skip the rest of tests if this one fails\n    expect(true).to.be.true;\n  });\n\n  it(\"second test\",() =\u003e {\n    // Will continue executing tests if this one fails\n    expect(true).to.be.true;\n  });\n});\n```\n\n### Configuration examples for usual scenarios\n\n##### You want to disable \"fail-fast\" in all specs except one:\n\nSet the `FAIL_FAST_ENABLED` key in the `cypress.json` configuration file:\n\n```json\n{\n  \"env\":\n  {\n    \"FAIL_FAST_ENABLED\": false\n  }\n}\n```\n\nEnable \"fail-fast\" in those specs you want using [configurations by test](#configuration-by-test):\n\n```js\ndescribe(\"All tests\", { failFast: { enabled: true } }, () =\u003e {\n  // If any test in this describe fails, the rest of tests and specs will be skipped\n});\n```\n\n##### You want to totally disable \"fail-fast\" in your local environment:\n\nSet the `FAIL_FAST_PLUGIN` key in your local `cypress.env.json` configuration file:\n\n```json\n{\n  \"env\":\n  {\n    \"FAIL_FAST_PLUGIN\": false\n  }\n}\n```\n\n### Configuration for parallel runs\n\nThe plugin configuration supports defining two callbacks that, used in combination, allow to skip tests in one run when other run starts skipping tests also. Where, or how do you store the \"flag\" that allows to communicate your runs is in your hands, the plugin does not care about it.\n\nTo implement it, the plugin can receive an object with extra configuration as third argument when it is registered in the `cypress/plugins/index.js` file:\n\n* __`parallelCallbacks`__: Object containing next properties:\n  * __`onCancel`__: `function()` This callback is executed on first test failure that produces the plugin starts skipping tests.\n  * __`isCancelled`__: `function(): boolean` If this callback returns `true`, the plugin skips remaining tests.\n\nThese callbacks are executed only when the environment variable `FAIL_FAST_STRATEGY` is set to `parallel`.\n\nHere is an example of configuration that would skip tests on many parallel runs when one of them starts skipping tests. It would only work if all parallel runs have access to the folder where the `isCancelled` flag is being stored as a file (easy to achieve if all of your parallel runs are being executed on Docker images on a same machine, for example). _Note that this is only an example, you could also implement it storing the flag in a REST API, etc._\n\n```js\n// Example valid for Cypress versions lower than 10. Use config file on Cypress 10\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Flag file is stored in the /cypress folder\nconst isCancelledFlagFile = path.resolve(__dirname, \"..\", \".run-is-cancelled\");\n\nmodule.exports = (on, config) =\u003e {\n  require(\"cypress-fail-fast/plugin\")(on, config, {\n    parallelCallbacks: {\n      onCancel: () =\u003e {\n        // Create flag file when the plugin starts skipping tests\n        fs.writeFileSync(isCancelledFlagFile, \"\");\n      },\n      isCancelled: () =\u003e {\n        // If any other run has created the file, start skipping tests\n        return fs.existsSync(isCancelledFlagFile);\n      },\n    },\n  });\n\n  return config;\n};\n```\n\nNote that this example requires to remove the created file when all of the runs have finished, or tests will always be skipped whenever any run starts again. So, the `FAIL_FAST_STRATEGY` environment variable should be set to `parallel` only in CI pipelines where the workspace is cleaned on finish, for example. \n\n## Usage with TypeScript\n\nIf you are using [TypeScript in the Cypress plugins file][cypress-typescript], this plugin includes TypeScript declarations and can be imported like the following:\n\n```ts\nimport cypressFailFast = require(\"cypress-fail-fast/plugin\");\n\nexport default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Cypress.PluginConfigOptions =\u003e {\n  cypressFailFast(on, config);\n  return config;\n};\n```\n\nNote: The example above is only valid for Cypress versions lower than 10. Use the configuration file in Cypress 10.\n\n## Tests\n\nTo ensure the plugin stability, the current major version is being tested with Cypress major versions 9.x, 10.x, 11.x, 12.x and 13.x, and new releases will be published for each new Cypress minor or major releases, updating the E2E tests.\n\nMinor versions used in the E2E tests can be checked in the `devDependencies` of the `package.json` files of the E2E tests:\n* [Cypress v9.x](https://github.com/javierbrea/cypress-fail-fast/blob/main/test-e2e/cypress-variants/cypress-9/package.json)\n* [Cypress v10.x](https://github.com/javierbrea/cypress-fail-fast/blob/main/test-e2e/cypress-variants/cypress-10/package.json)\n* [Cypress v11.x](https://github.com/javierbrea/cypress-fail-fast/blob/main/test-e2e/cypress-variants/cypress-11/package.json)\n* [Cypress v12.x](https://github.com/javierbrea/cypress-fail-fast/blob/main/test-e2e/cypress-variants/cypress-12/package.json)\n* [Cypress v13.x](https://github.com/javierbrea/cypress-fail-fast/blob/main/test-e2e/cypress-variants/cypress-13/package.json)\n\nEven when current major version may work with previous Cypress versions, it is not currently tested, so, to be sure it works you should use:\n\n* Cypress 8.x may work, but it was tested until `cypress-fail-fast` 7.0.x\n* If you need Cypress 7 support, use `cypress-fail-fast` 6.x\n* If you need Cypress 6 support, use `cypress-fail-fast` 5.x\n* If you need Cypress 5 or lower, use `cypress-fail-fast` \u003c= 4.x\n\nIf you find any issue for a specific Cypress version, please report it at https://github.com/javierbrea/cypress-fail-fast/issues.\n\n## Acknowledgements\n\nThis plugin has been developed based on the solutions proposed by the community on this [Cypress issue](https://github.com/cypress-io/cypress/issues/518), so thanks to all! I hope this plugin can be deprecated soon, as soon as the Cypress team adds native support for this feature. 😃\n\n## Contributing\n\nContributors are welcome.\nPlease read the [contributing guidelines](.github/CONTRIBUTING.md) and [code of conduct](.github/CODE_OF_CONDUCT.md).\n\n## License\n\nMIT, see [LICENSE](./LICENSE) for details.\n\n[coveralls-image]: https://coveralls.io/repos/github/javierbrea/cypress-fail-fast/badge.svg\n[coveralls-url]: https://coveralls.io/github/javierbrea/cypress-fail-fast\n[build-image]: https://github.com/javierbrea/cypress-fail-fast/workflows/build/badge.svg?branch=main\n[build-url]: https://github.com/javierbrea/cypress-fail-fast/actions?query=workflow%3Abuild+branch%3Amain\n[last-commit-image]: https://img.shields.io/github/last-commit/javierbrea/cypress-fail-fast.svg\n[last-commit-url]: https://github.com/javierbrea/cypress-fail-fast/commits\n[license-image]: https://img.shields.io/npm/l/cypress-fail-fast.svg\n[license-url]: https://github.com/javierbrea/cypress-fail-fast/blob/main/LICENSE\n[npm-downloads-image]: https://img.shields.io/npm/dm/cypress-fail-fast.svg\n[npm-downloads-url]: https://www.npmjs.com/package/cypress-fail-fast\n[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=javierbrea_cypress-fail-fast\u0026metric=alert_status\n[quality-gate-url]: https://sonarcloud.io/dashboard?id=javierbrea_cypress-fail-fast\n[release-image]: https://img.shields.io/github/release-date/javierbrea/cypress-fail-fast.svg\n[release-url]: https://github.com/javierbrea/cypress-fail-fast/releases\n\n[cypress-typescript]: https://docs.cypress.io/guides/tooling/typescript-support.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavierbrea%2Fcypress-fail-fast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavierbrea%2Fcypress-fail-fast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavierbrea%2Fcypress-fail-fast/lists"}