From 5453abd6ad2f3133ea79f6e630903844e340bd0c Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 20 Dec 2023 08:52:56 +0100 Subject: [PATCH] doc: set exit code in custom test runner example Signed-off-by: Matteo Collina PR-URL: https://github.com/nodejs/node/pull/51056 Reviewed-By: Chemi Atlow Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow Reviewed-By: James M Snell --- doc/api/test.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index ce526d17ae7e2b..156b7835295c6f 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1154,8 +1154,11 @@ import process from 'node:process'; import path from 'node:path'; run({ files: [path.resolve('./tests/test.js')] }) - .compose(tap) - .pipe(process.stdout); + .on('test:fail', () => { + process.exitCode = 1; + }) + .compose(tap) + .pipe(process.stdout); ``` ```cjs @@ -1164,8 +1167,11 @@ const { run } = require('node:test'); const path = require('node:path'); run({ files: [path.resolve('./tests/test.js')] }) - .compose(tap) - .pipe(process.stdout); + .on('test:fail', () => { + process.exitCode = 1; + }) + .compose(tap) + .pipe(process.stdout); ``` ## `test([name][, options][, fn])`