{"id":15558481,"url":"https://github.com/lukesavefrogs/jest-failfast","last_synced_at":"2026-04-13T11:32:08.167Z","repository":{"id":40258440,"uuid":"493383304","full_name":"LukeSavefrogs/jest-failfast","owner":"LukeSavefrogs","description":"A configurable Jest Environment to allow for finer grade control over the way Jest handles failed tests.","archived":false,"fork":false,"pushed_at":"2023-12-15T05:07:35.000Z","size":172,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-30T22:31:22.954Z","etag":null,"topics":["bdd","circus","fail","failfast","fast","jest","jest-environment","steps"],"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/LukeSavefrogs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"LukeSavefrogs","patreon":"LukeSavefrogs","ko_fi":"lukesavefrogs","custom":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RN3XMAHA8FZEE\u0026source=url"]}},"created_at":"2022-05-17T19:15:23.000Z","updated_at":"2022-12-02T00:52:22.000Z","dependencies_parsed_at":"2023-02-08T09:00:45.276Z","dependency_job_id":null,"html_url":"https://github.com/LukeSavefrogs/jest-failfast","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LukeSavefrogs/jest-failfast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjest-failfast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjest-failfast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjest-failfast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjest-failfast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeSavefrogs","download_url":"https://codeload.github.com/LukeSavefrogs/jest-failfast/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjest-failfast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bdd","circus","fail","failfast","fast","jest","jest-environment","steps"],"created_at":"2024-10-02T15:35:11.019Z","updated_at":"2026-04-13T11:32:08.150Z","avatar_url":"https://github.com/LukeSavefrogs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/LukeSavefrogs","https://patreon.com/LukeSavefrogs","https://ko-fi.com/lukesavefrogs","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RN3XMAHA8FZEE\u0026source=url"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003ch1 align=\"center\"\u003eFailFast\u003c/h1\u003e\n\t\u003cp align=\"center\"\u003e\n\t\t\u003cstrong\u003e\u003ci\u003eA configurable Jest Environment\u003c/i\u003e\u003c/strong\u003e\n\t\u003c/p\u003e\n\u003c/p\u003e\n\n## Description\nThis package allows to have more control over the way Jest handles failed tests.\n\nIt has been inspired by [**Jest Environment Steps**](https://www.npmjs.com/package/jest-environment-steps) and [**this S.O. answer**](https://stackoverflow.com/questions/51250006/jest-stop-test-suite-after-first-fail/65904327#65904327).\n\nQuoting from \"Jest Environment Steps\" \u003e Overview:\n\u003e \"In Jest, all tests with in a describe block run sequentially in the order of their appearance. But if a tests fails, the next tests continue to execute.\n\u003e \n\u003e For writing tests for a behaviour where each test depends on success of previous test, this built-in feature may cause unnecessory tests to run\n\u003e \n\u003e Example of behaviour tests.\n\u003e\n\u003e Testing a CRUD apis on a database. Writing test for Create, Read, Update and Delete in the same sequence makes the it sense to test all apis in same order. and if Create fails, there is no pointing testing if the read, update and delete.\"\n\nJest FailFast has the same functionality, and some more useful features. \n\n### Features\n- Global (as in [**Jest Environment Steps**](https://www.npmjs.com/package/jest-environment-steps)) or block-scoped test failures;\n- Mark `describe` blocks as optional (if a failure happens it does not propagate)\n\n\n## Configuration\nTo use it, you just need to add the following lines at the top of the test file:\n```Javascript\n/**\n * This tells Jest to use our custom Environment for this specific file.\n * \n * @jest-environment \u003crootDir\u003e/src/jest-environment.js\n * @jest-environment-options { \"failFast\": {\"enabled\": true, \"scope\": \"global\"} }\n */\n```\n\nFrom there, you'll be able to change the configuration using the following schema:\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth\u003eOption name\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003cth\u003eType\u003c/th\u003e\u003cth\u003eDefault\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003everbose\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tIf set to true increases the verbosity of the messages printed on screen.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\n\t\t\t\tUsed for debugging.\n\t\t\t\u003c/td\u003e\n\t\t\t\u003ctd\u003eBoolean\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003efailFast.enabled\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tWether to enable the failFast option or not.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\n\t\t\t\tSetting it to \u003ccode\u003efalse\u003c/code\u003e fallbacks to the original Jest behaviour.\n\t\t\t\u003c/td\u003e\n\t\t\t\u003ctd\u003eBoolean\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003efailFast.scope\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tThe scope of the failure:\n\t\t\t\t\u003cul\u003e\n\t\t\t\t\t\u003cli\u003e\u003ccode\u003eglobal\u003c/code\u003e: A single test failure will cause the entire test suite to fail.\u003c/li\u003e\n\t\t\t\t\t\u003cli\u003e\u003ccode\u003eblock\u003c/code\u003e: A single test failure will cause to fail only the nearest \u003ccode\u003edescribe\u003c/code\u003e block to fail. All subsequent tests inside that block will be skipped.\u003c/li\u003e\n\t\t\t\t\u003c/ul\u003e\n\t\t\t\tTakes effect only if \u003ccode\u003efailFast.enabled\u003c/code\u003e is set to \u003ccode\u003etrue\u003c/code\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003e\"global\"|\"block\"\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003eglobal\u003c/code\u003e\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Methods\n#### `testEnvironment.markBlockAsOptional()`\nMarks the current `describe` block as \"optional\". This means that any test failure inside that block won't cause a test suite failure **even if** `failFast.scope` is set to `global`.\n\nThis is used when you don't want that block status to influence the test suite exit code (i.e. some preconditions or tests that *may fail*).\n\n#### `testEnvironment.setVerbose(boolean)`\nProgrammatically set the `verbose` option.\n\n#### `testEnvironment.registerTestEventHandler(function)`\n\u003e Originally made by [@ysfaran](https://github.com/ysfaran) for [this SO answer](https://stackoverflow.com/a/65904327/8965861).\n\u003e \nUse this method to specify a [custom function](https://jestjs.io/docs/configuration#testenvironment-string#:~:text=handleTestEvent) that will be called for **every event fired by Jest**.\n\n\n##### Example\nIn the following example it will be called the `takeScreenshot()` function whenever a **test fails**:\n```Javascript\n// The `testEnvironment` variable is globally available\ntestEnvironment.registerTestEventHandler(async (event, state) =\u003e {\n\tif (event.name === \"test_fn_failure\") {\n\t\tawait takeScreenshot()\n\t}\n})\n```\n\n##### Events\nThe up-to-date list of events can be found [here](https://github.com/facebook/jest/blob/main/packages/jest-types/src/Circus.ts). These are the ones i found **most useful**:\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth colSpan=2\u003e\u003ccenter\u003e\u003cb\u003e\u003ci\u003eTest suite\u003c/i\u003e\u003c/b\u003e\u003c/center\u003e\u003c/th\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003cth\u003eEvent name\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003esetup\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFirst event to be fired.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\n\t\t\t\tCan be used to define a \u003ccode\u003econstructor\u003c/code\u003e of sorts.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003eteardown\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tLast event to be fired.\u003cbr\u003e\n\t\t\t\t\u003cbr\u003e\n\t\t\t\tFired after everything is finished. Can be used to define a \u003ccode\u003edestructor\u003c/code\u003e of sorts.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth colSpan=2\u003e\u003ccenter\u003e\u003cb\u003e\u003ci\u003e\u003ccode\u003etest\u003c/code\u003e block\u003c/i\u003e\u003c/b\u003e\u003c/center\u003e\u003c/th\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003cth\u003eEvent name\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003etest_start\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tA test has \u003cb\u003estarted\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003etest_skip\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tA test has been \u003cb\u003eskipped\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003etest_fn_start\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFired when the \u003cb\u003efunction passed\u003c/b\u003e to a \u003ccode\u003etest\u003c/code\u003e \u003cb\u003estarts\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003etest_fn_failure\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFired when the \u003cb\u003efunction passed\u003c/b\u003e to a \u003ccode\u003etest\u003c/code\u003e \u003cb\u003efails\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003etest_fn_success\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFired when the \u003cb\u003efunction passed\u003c/b\u003e to a \u003ccode\u003etest\u003c/code\u003e \u003cb\u003esucceeds\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth colSpan=2\u003e\u003ccenter\u003e\u003cb\u003e\u003ci\u003e\u003ccode\u003edescribe\u003c/code\u003e block\u003c/i\u003e\u003c/b\u003e\u003c/center\u003e\u003c/th\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003cth\u003eEvent name\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003erun_describe_start\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFired when a \u003ccode\u003edescribe\u003c/code\u003e block \u003cb\u003estarts\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ccode\u003erun_describe_finish\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\n\t\t\t\tFired when a \u003ccode\u003edescribe\u003c/code\u003e block \u003cb\u003eends\u003c/b\u003e.\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Sources\n- [This answer](https://stackoverflow.com/questions/51250006/jest-stop-test-suite-after-first-fail/65904327#65904327)\n- [This package](https://www.npmjs.com/package/jest-environment-steps), which corresponds to this package with the `{ failFast: {enabled: true, scope: \"global\"} }` configuration.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukesavefrogs%2Fjest-failfast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukesavefrogs%2Fjest-failfast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukesavefrogs%2Fjest-failfast/lists"}