Skip to content

Commit fe65996

Browse files
LiviaMedeirostargos
authored andcommitted
doc: clarify guide on testing internal errors
PR-URL: #42813 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
1 parent b85a11c commit fe65996

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/contributing/writing-tests.md

+12
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,18 @@ assert.throws(
312312
);
313313
```
314314

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

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

0 commit comments

Comments
 (0)