From 1a23c68c3afd9fda94c88b7f04de39a3de7f18dc Mon Sep 17 00:00:00 2001 From: Ognjen Jevremovic Date: Fri, 19 Jan 2024 11:58:11 +0100 Subject: [PATCH 1/5] doc: clarify execution of `after` hook on test suite completion The `after` hook now explicitly mentions that it is executed once after all the tests in a test suite have completed, regardless of whether the tests passed or failed. This ensures that cleanup tasks or actions specified in the after hook are guaranteed to run. Refs: https://github.com/nodejs/node/issues/50901 --- doc/api/test.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/api/test.md b/doc/api/test.md index 5f2d3dfad56cd0..05c8c901a56b4f 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1420,6 +1420,13 @@ describe('tests', async () => { }); ``` +**Note:** The `after` hook is executed once after all the tests +in a test suite have completed, regardless of whether the tests +passed or failed. This hook is useful for performing cleanup tasks +or actions that should occur after the entire test suite has been run. +It's important to note that the `after` hook is guaranteed to run, +even if tests within the suite fail. + ## `beforeEach([fn][, options])`