@@ -445,18 +445,26 @@ 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. Because the test files
463
+ are all run within the same context, it is possible for tests to interact with
464
+ each other in ways that are not possible when isolation is enabled. For example,
465
+ if a test relies on global state, it is possible for that state to be modified
466
+ by a test originating from another file.
467
+
460
468
## Collecting code coverage
461
469
462
470
> Stability: 1 - Experimental
@@ -933,7 +941,7 @@ the [`--experimental-test-snapshots`][] command-line flag.
933
941
Snapshot files are generated by starting Node.js with the
934
942
[ ` --test-update-snapshots ` ] [ ] command-line flag. A separate snapshot file is
935
943
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
944
+ as the test file with a ` .snapshot ` file extension. This behavior can be
937
945
configured using the ` snapshot.setResolveSnapshotPath() ` function. Each
938
946
snapshot assertion corresponds to an export in the snapshot file.
939
947
@@ -1239,6 +1247,9 @@ added:
1239
1247
- v18.9.0
1240
1248
- v16.19.0
1241
1249
changes:
1250
+ - version: REPLACEME
1251
+ pr-url: https://github.com/nodejs/node/pull/53927
1252
+ description: Added the `isolation` option.
1242
1253
- version: v22.6.0
1243
1254
pr-url: https://github.com/nodejs/node/pull/53866
1244
1255
description: Added the `globPatterns` option.
@@ -1272,8 +1283,13 @@ changes:
1272
1283
* ` inspectPort ` {number|Function} Sets inspector port of test child process.
1273
1284
This can be a number, or a function that takes no arguments and returns a
1274
1285
number. If a nullish value is provided, each process gets its own port,
1275
- incremented from the primary's ` process.debugPort ` .
1276
- ** Default:** ` undefined ` .
1286
+ incremented from the primary's ` process.debugPort ` . This option is ignored
1287
+ if the ` isolation ` option is set to ` 'none' ` as no child processes are
1288
+ spawned. ** Default:** ` undefined ` .
1289
+ * ` isolation ` {string} Configures the type of test isolation. If set to
1290
+ ` 'process' ` , each test file is run in a separate child process. If set to
1291
+ ` 'none' ` , all test files run in the current process. ** Default:**
1292
+ ` 'process' ` .
1277
1293
* ` only ` : {boolean} If truthy, the test context will only run tests that
1278
1294
have the ` only ` option set
1279
1295
* ` setup ` {Function} A function that accepts the ` TestsStream ` instance
@@ -1717,9 +1733,9 @@ added: v22.3.0
1717
1733
1718
1734
* ` fn ` {Function} A function used to compute the location of the snapshot file.
1719
1735
The function receives the path of the test file as its only argument. If the
1720
- ` process.argv[1] ` is not associated with a file (for example in the REPL),
1721
- the input is undefined. ` fn() ` must return a string specifying the location of
1722
- the snapshot file.
1736
+ test is not associated with a file (for example in the REPL), the input is
1737
+ undefined. ` fn() ` must return a string specifying the location of the snapshot
1738
+ snapshot file.
1723
1739
1724
1740
This function is used to customize the location of the snapshot file used for
1725
1741
snapshot testing. By default, the snapshot filename is the same as the entry
0 commit comments