test: ensure assertions are reached on more tests

PR-URL: https://github.com/nodejs/node/pull/60641
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Antoine du Hamel
2025-11-11 11:56:18 +02:00
committed by GitHub
parent 57b4a315ce
commit f1f6f3df84
78 changed files with 324 additions and 297 deletions

View File

@@ -135,10 +135,10 @@ function assertDirents(dirents) {
assert.strictEqual(dirents.length, expected.length);
dirents.sort((a, b) => (getDirentPath(a) < getDirentPath(b) ? -1 : 1));
assert.deepStrictEqual(
dirents.map((dirent) => {
dirents.map(common.mustCallAtLeast((dirent) => {
assert(dirent instanceof fs.Dirent);
return getDirentPath(dirent);
}),
})),
expected
);
}

View File

@@ -26,12 +26,12 @@ const server = http.createServer(common.mustCall((req, res) => {
res.write(content);
res.end();
}));
server.on('timeout', () => {
server.on('timeout', common.mustCallAtLeast(() => {
// TODO(apapirovski): This test is faulty on certain Windows systems
// as no queue is ever created
assert(!socket._handle || socket._handle.writeQueueSize === 0,
'Should not timeout');
});
}, 0));
server.listen(0, common.mustCall(() => {
http.get({

View File

@@ -102,7 +102,7 @@ server.listen(0, common.mustCall(() => {
request5.client.write(requestBodyPart2);
}, headersTimeout * 0.8);
setTimeout(() => {
setTimeout(common.mustCall(() => {
// After the first timeout, the first request should have been completed and second timedout
assert(request1.completed);
assert(request2.completed);
@@ -112,14 +112,14 @@ server.listen(0, common.mustCall(() => {
assert(request1.response.startsWith(responseOk));
assert(request2.response.startsWith(responseTimeout)); // It is expired due to headersTimeout
}, headersTimeout * 1.4);
}), headersTimeout * 1.4);
setTimeout(() => {
// Complete the body for the fourth request
request4.client.write(requestBodyPart3);
}, headersTimeout * 1.5);
setTimeout(() => {
setTimeout(common.mustCall(() => {
// All request should be completed now, either with 200 or 408
assert(request3.completed);
assert(request4.completed);
@@ -129,5 +129,5 @@ server.listen(0, common.mustCall(() => {
assert(request4.response.startsWith(responseOk));
assert(request5.response.startsWith(responseTimeout)); // It is expired due to requestTimeout
server.close();
}, headersTimeout * 3 + connectionsCheckingInterval);
}), headersTimeout * 3 + connectionsCheckingInterval);
}));