From 92f163e4655b738370c781edc72bdd1b6bbfe8dd Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Mon, 7 Nov 2016 09:27:37 -0500 Subject: [PATCH] doc: clarify the exit code part of writing_tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/9502 Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Daniel Bevenius Reviewed-By: Luigi Pinca --- doc/guides/writing_tests.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/guides/writing_tests.md b/doc/guides/writing_tests.md index 169a9c8e5fa11f..d00be9cdbcc4c6 100644 --- a/doc/guides/writing_tests.md +++ b/doc/guides/writing_tests.md @@ -3,11 +3,13 @@ ## What is a test? A test must be a node script that exercises a specific functionality provided -by node and checks that it behaves as expected. It should return 0 on success, +by node and checks that it behaves as expected. It should exit with code `0` on success, otherwise it will fail. A test will fail if: -- It exits by calling `process.exit(code)` where `code != 0` -- It exits due to an uncaught exception. +- It exits by setting `process.exitCode` to a non-zero number. + - This is most often done by having an assertion throw an uncaught + Error. + - Occasionally, using `process.exit(code)` may be appropriate. - It never exits. In this case, the test runner will terminate the test because it sets a maximum time limit.