@@ -445,18 +445,22 @@ in the [test runner execution model][] section.
445
445
446
446
### Test runner execution model
447
447
448
- Each matching test file is executed in a separate child process. The maximum
449
- number of child processes running at any time is controlled by the
450
- [ ` --test-concurrency ` ] [ ] flag. If the child process finishes with an exit code
451
- of 0, the test is considered passing. Otherwise , the test is considered to be a
452
- failure. Test files must be executable by Node.js, but are not required to use
453
- the ` node:test ` module internally.
448
+ When process-level test isolation is enabled, each matching test file is
449
+ executed in a separate child process. The maximum number of child processes
450
+ running at any time is controlled by the [ ` --test-concurrency ` ] [ ] flag. If the
451
+ child process finishes with an exit code of 0 , the test is considered passing.
452
+ Otherwise, the test is considered to be a failure. Test files must be executable
453
+ by Node.js, but are not required to use the ` node:test ` module internally.
454
454
455
455
Each test file is executed as if it was a regular script. That is, if the test
456
456
file itself uses ` node:test ` to define tests, all of those tests will be
457
457
executed within a single application thread, regardless of the value of the
458
458
` concurrency ` option of [ ` test() ` ] [ ] .
459
459
460
+ When process-level test isolation is disabled, each matching test file is
461
+ imported into the test runner process. Once all test files have been loaded, the
462
+ top level tests are executed with a concurrency of one.
463
+
460
464
## Collecting code coverage
461
465
462
466
> Stability: 1 - Experimental
@@ -933,7 +937,7 @@ the [`--experimental-test-snapshots`][] command-line flag.
933
937
Snapshot files are generated by starting Node.js with the
934
938
[ ` --test-update-snapshots ` ] [ ] command-line flag. A separate snapshot file is
935
939
generated for each test file. By default, the snapshot file has the same name
936
- as ` process.argv[1] ` with a ` .snapshot ` file extension. This behavior can be
940
+ as the test file with a ` .snapshot ` file extension. This behavior can be
937
941
configured using the ` snapshot.setResolveSnapshotPath() ` function. Each
938
942
snapshot assertion corresponds to an export in the snapshot file.
939
943
@@ -1239,6 +1243,9 @@ added:
1239
1243
- v18.9.0
1240
1244
- v16.19.0
1241
1245
changes:
1246
+ - version: REPLACEME
1247
+ pr-url: https://github.com/nodejs/node/pull/53927
1248
+ description: Added the `isolation` option.
1242
1249
- version: v22.6.0
1243
1250
pr-url: https://github.com/nodejs/node/pull/53866
1244
1251
description: Added the `globPatterns` option.
@@ -1274,8 +1281,13 @@ changes:
1274
1281
* ` inspectPort ` {number|Function} Sets inspector port of test child process.
1275
1282
This can be a number, or a function that takes no arguments and returns a
1276
1283
number. If a nullish value is provided, each process gets its own port,
1277
- incremented from the primary's ` process.debugPort ` .
1278
- ** Default:** ` undefined ` .
1284
+ incremented from the primary's ` process.debugPort ` . This option is ignored
1285
+ if the ` isolation ` option is set to ` 'none' ` as no child processes are
1286
+ spawned. ** Default:** ` undefined ` .
1287
+ * ` isolation ` {string} Configures the type of test isolation. If set to
1288
+ ` 'process' ` , each test file is run in a separate child process. If set to
1289
+ ` 'none' ` , all test files run in the current process. The default isolation
1290
+ mode is ` 'process' ` .
1279
1291
* ` only ` : {boolean} If truthy, the test context will only run tests that
1280
1292
have the ` only ` option set
1281
1293
* ` setup ` {Function} A function that accepts the ` TestsStream ` instance
@@ -1727,9 +1739,9 @@ added: v22.3.0
1727
1739
1728
1740
* ` fn ` {Function} A function used to compute the location of the snapshot file.
1729
1741
The function receives the path of the test file as its only argument. If the
1730
- ` process.argv[1] ` is not associated with a file (for example in the REPL),
1731
- the input is undefined. ` fn() ` must return a string specifying the location of
1732
- the snapshot file.
1742
+ test is not associated with a file (for example in the REPL), the input is
1743
+ undefined. ` fn() ` must return a string specifying the location of the snapshot
1744
+ snapshot file.
1733
1745
1734
1746
This function is used to customize the location of the snapshot file used for
1735
1747
snapshot testing. By default, the snapshot filename is the same as the entry
0 commit comments