{"id":17222915,"url":"https://github.com/rush/mocha-finalize-each","last_synced_at":"2025-03-25T16:22:29.558Z","repository":{"id":139264988,"uuid":"100815527","full_name":"Rush/mocha-finalize-each","owner":"Rush","description":"Finalize each test in a mocha test suite and conditionally fail. This is a better afterEach.","archived":false,"fork":false,"pushed_at":"2018-06-10T04:09:42.000Z","size":9,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T14:25:41.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Rush.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}},"created_at":"2017-08-19T19:03:19.000Z","updated_at":"2023-04-02T12:27:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"23429921-010e-42e5-840b-92f2cbd0c363","html_url":"https://github.com/Rush/mocha-finalize-each","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fmocha-finalize-each","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fmocha-finalize-each/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fmocha-finalize-each/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fmocha-finalize-each/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rush","download_url":"https://codeload.github.com/Rush/mocha-finalize-each/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245496447,"owners_count":20624886,"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":[],"created_at":"2024-10-15T04:06:42.305Z","updated_at":"2025-03-25T16:22:29.529Z","avatar_url":"https://github.com/Rush.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mocha-finalize-each\nFinalize each test in a mocha test suite and conditionally fail. This is a better afterEach. Stock `afterEach` halts the whole suite https://github.com/mochajs/mocha/issues/1635 in case of any `afterEach` failure\n\n## Example\n\nBelow supports all types of tests: sync, async and promises. It unifies them to use promises so that `finalizeEach` can have a uniform interface.\n\n```js\nvar finalizeEach = require('mocha-finalize-each');\n\ndescribe('some tests', function() {\n  var sinonSandbox = sinon.sandbox.create();\n\n  // promise will be resolved after the test code resolves\n  finalizeEach(this, promise =\u003e {\n    // note: always return a promise here\n    // note2: if you .catch an error and don't re-throw it your tests will always pass\n    return promise.then(() =\u003e {\n      // will fail tests if sinon assertions are not satisfied\n      sinonSandbox.verifyAndRestore();\n    }).finally(() =\u003e {\n      // clean in all cases\n      sinonSandbox.restore();\n    });\n  });\n\n  it('some test', function() {\n     /* ...  some code using sinonSandbox */\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Fmocha-finalize-each","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frush%2Fmocha-finalize-each","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Fmocha-finalize-each/lists"}