Skip to content

Commit 979e183

Browse files
mcollinarichardlau
authored andcommittedMar 25, 2024
doc: set exit code in custom test runner example
Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #51056 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent efd6630 commit 979e183

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎doc/api/test.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,11 @@ import process from 'node:process';
11731173
import path from 'node:path';
11741174

11751175
run({ files: [path.resolve('./tests/test.js')] })
1176-
.compose(tap)
1177-
.pipe(process.stdout);
1176+
.on('test:fail', () => {
1177+
process.exitCode = 1;
1178+
})
1179+
.compose(tap)
1180+
.pipe(process.stdout);
11781181
```
11791182

11801183
```cjs
@@ -1183,8 +1186,11 @@ const { run } = require('node:test');
11831186
const path = require('node:path');
11841187

11851188
run({ files: [path.resolve('./tests/test.js')] })
1186-
.compose(tap)
1187-
.pipe(process.stdout);
1189+
.on('test:fail', () => {
1190+
process.exitCode = 1;
1191+
})
1192+
.compose(tap)
1193+
.pipe(process.stdout);
11881194
```
11891195

11901196
## `test([name][, options][, fn])`

0 commit comments

Comments
 (0)
Please sign in to comment.