You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These modules are required for the test to run. Except for special cases, these
90
-
modules should only include core modules.
91
-
The `assert` module is used by most of the tests to check that the assumptions
92
-
for the test are met.
93
-
Note that require statements are sorted, in
90
+
The test checks functionality in the `http` module.
91
+
92
+
Most tests use the `assert` module to confirm expectations of the test.
93
+
94
+
The require statements are sorted in
94
95
[ASCII](http://man7.org/linux/man-pages/man7/ascii.7.html) order (digits, upper
95
96
case, `_`, lower case).
96
97
97
98
### **Lines 10-21**
98
99
99
-
This is the body of the test. This test is quite simple, it just tests that an
100
+
This is the body of the test. This test is simple, it just tests that an
100
101
HTTP server accepts `non-ASCII` characters in the headers of an incoming
101
102
request. Interesting things to notice:
102
103
103
-
- If the test doesn't depend on a specific port number then always use 0 instead
104
-
of an arbitrary value, as it allows tests to be run in parallel safely, as the
105
-
operating system will assign a random port. If the test requires a specific
106
-
port, for example if the test checks that assigning a specific port works as
107
-
expected, then it is ok to assign a specific port number.
104
+
- If the test doesn't depend on a specific port number, then always use 0
105
+
instead of an arbitrary value, as it allows tests to run in parallel safely,
106
+
as the operating system will assign a random port. If the test requires a
107
+
specific port, for example if the test checks that assigning a specific port
108
+
works as expected, then it is ok to assign a specific port number.
108
109
- The use of `common.mustCall` to check that some callbacks/listeners are
109
110
called.
110
-
- The HTTP server is closed once all the checks have run. This way, the test can
111
+
- The HTTP server closes once all the checks have run. This way, the test can
111
112
exit gracefully. Remember that for a test to succeed, it must exit with a
112
113
status code of 0.
113
114
114
115
## General recommendations
115
116
116
117
### Timers
117
118
118
-
The use of timers is discouraged, unless timers are being tested. There are
119
-
multiple reasons for this. Mainly, they are a source of flakiness. For a thorough
119
+
Avoid timers unless the test is specifically testing timers. There are multiple
120
+
reasons for this. Mainly, they are a source of flakiness. For a thorough
120
121
explanation go [here](https://github.com/nodejs/testing/issues/27).
121
122
122
-
In the event a timer is needed, it's recommended using the
123
-
`common.platformTimeout()` method, that allows setting specific timeouts
123
+
In the event a test needs a timer, consider using the
124
+
`common.platformTimeout()` method. It allows setting specific timeouts
0 commit comments