Skip to content

Commit 5b2dfad

Browse files
Aditi-1400targos
authored andcommitted
doc: add a note about require('../common') in testing documentation
PR-URL: #56953 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 40f3a51 commit 5b2dfad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/common/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
# Node.js Core Test Common Modules
22

33
This directory contains modules used to test the Node.js implementation.
4+
All tests must begin by requiring the `common` module:
5+
6+
```js
7+
require('../common');
8+
```
9+
10+
This is not just a convenience for exporting helper functions etc; it also performs
11+
several other tasks:
12+
13+
* Verifies that no unintended globals have been leaked to ensure that tests
14+
don't accidentally pollute the global namespace.
15+
16+
* Some tests assume a default umask of `0o022`. To enforce this assumption,
17+
the common module sets the unmask at startup. Tests that require a
18+
different umask can override this setting after loading the module.
19+
20+
* Some tests specify runtime flags (example, `--expose-internals`) via a
21+
comment at the top of the file: `// Flags: --expose-internals`.
22+
If the test is run without those flags, the common module automatically
23+
spawns a child process with proper flags. This ensures that the tests
24+
always run under the expected conditions. Because of this behaviour, the
25+
common module must be loaded first so that any code below it is not
26+
executed until the process has been re-spawned with the correct flags.
427

528
## Table of contents
629

0 commit comments

Comments
 (0)