Skip to content

Commit f2ba9b6

Browse files
committed
Revert "Apply suggestion from @samayer12"
This reverts commit 29ddaeb.
1 parent 8e69a9f commit f2ba9b6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

docs/docs/best-practices/writing-tests.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ test('example with disconnect guard', async (t) => {
4646
```
4747

4848
The guard listens for `'disconnect'` events and calls `t.fail()` unless the
49-
client is already closing or destroyed. Skip the guard for tests where a disconnect is expected behavior, such as:
49+
client is already closing or destroyed. `client.close()` and `client.destroy()`
50+
both emit `'disconnect'` events, but those are expected — the guard skips them
51+
by checking `!client.closed && !client.destroyed`.
52+
53+
Skip the guard for tests where a disconnect is expected behavior, such as:
5054

5155
- Signal aborts (`signal.emit('abort')`, `ac.abort()`)
5256
- Server-side destruction (`res.destroy()`, `req.socket.destroy()`)

0 commit comments

Comments
 (0)