-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add restrictions around node:test usage #56027
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,27 @@ request. Interesting things to notice: | |
|
||
## General recommendations | ||
|
||
### Usage of `node:test` | ||
|
||
It is optional to use `node:test` in tests outside of testing the `node:test` | ||
module, as long as the functionality being tested is not a dependency of the | ||
`node:test` module. This ensures that a bug in the test runner doesn't impact | ||
the outcome of the underlying dependencies' test results. | ||
|
||
These dependencies are: | ||
|
||
- `node:events` | ||
- `node:async_hooks` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me, but before removing the rest, what's your reasoning for keeping only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only place the test runner uses a stream is for emitting events. If you were going to include that, you may as well include event emitter as well since it is part of streams. The Also worth noting that the test runner is already used to test the test runner itself 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you recommend changes to the text, please?
anonrig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- `node:child_process` | ||
- `node:fs` | ||
- `node:streams` with the exception of WebStreams | ||
- `node:vm` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the files listed in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean? I don't follow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably worth adding anything related to the bootstrapping process to the list of things not to test with the test runner since I'm not sure you can be 100% certain the test runner itself is bootstrapped properly at that point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Most of) the files listed there are essential parts of the Node.js functionality that are used more ubiquitously, hence more likely to be depended on by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you recommend changes to the text, please? |
||
|
||
#### Caveats | ||
|
||
* `node:url` is excluded due to the extensive testing on web-platform tests. | ||
* `node:path` and `node:os` is excluded due to being used by both test runners. | ||
|
||
### Timers | ||
|
||
Avoid timers unless the test is specifically testing timers. There are multiple | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems important to document things like #52177 or otherwise we would see more flakes coming up once people start to spawn hundreds of child processes in parallel and overloading the machine using
spawnPromisified
+node:test
....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Using the concurrency option is fine though unless you are specifically planning to spawn child processes. But that applies to things like
Promise.all()
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you recommend changes to the text, please?