Skip to content

Commit 12eab82

Browse files
LiviaMedeirostargos
authored andcommitted
doc: clarify guide on testing internal errors
PR-URL: #42813 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Akhil Marsonya <[email protected]>
1 parent bbfa532 commit 12eab82

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/contributing/writing-tests.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,18 @@ assert.throws(
311311
);
312312
```
313313

314+
In the case of internal errors, prefer checking only the `code` property:
315+
316+
```js
317+
assert.throws(
318+
() => {
319+
throw new ERR_FS_FILE_TOO_LARGE(`${sizeKiB} Kb`);
320+
},
321+
{ code: 'ERR_FS_FILE_TOO_LARGE' }
322+
// Do not include message: /^File size ([0-9]+ Kb) is greater than 2 GiB$/
323+
);
324+
```
325+
314326
### Console output
315327

316328
Output written by tests to stdout or stderr, such as with `console.log()` or

0 commit comments

Comments
 (0)