Skip to content

Commit 92f163e

Browse files
Fishrock123addaleax
authored andcommitted
doc: clarify the exit code part of writing_tests
PR-URL: #9502 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 62478eb commit 92f163e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/guides/writing_tests.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
## What is a test?
44

55
A test must be a node script that exercises a specific functionality provided
6-
by node and checks that it behaves as expected. It should return 0 on success,
6+
by node and checks that it behaves as expected. It should exit with code `0` on success,
77
otherwise it will fail. A test will fail if:
88

9-
- It exits by calling `process.exit(code)` where `code != 0`
10-
- It exits due to an uncaught exception.
9+
- It exits by setting `process.exitCode` to a non-zero number.
10+
- This is most often done by having an assertion throw an uncaught
11+
Error.
12+
- Occasionally, using `process.exit(code)` may be appropriate.
1113
- It never exits. In this case, the test runner will terminate the test because
1214
it sets a maximum time limit.
1315

0 commit comments

Comments
 (0)