diff options
author | Livia Medeiros <74449973+LiviaMedeiros@users.noreply.github.com> | 2022-04-28 00:50:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-28 00:50:19 +0300 |
commit | fc485a9cbe552902e2c1880210f83170d9d951aa (patch) | |
tree | 7e6cb28008e81a64521097ae05b561def462486d /doc | |
parent | 8cbc39068cd102e3bbdb6c5a1d14ce450e6ef093 (diff) |
doc: clarify guide on testing internal errors
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/contributing/writing-tests.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index 6241cb68c96..c24526f0139 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -312,6 +312,18 @@ assert.throws( ); ``` +In the case of internal errors, prefer checking only the `code` property: + +```js +assert.throws( + () => { + throw new ERR_FS_FILE_TOO_LARGE(`${sizeKiB} Kb`); + }, + { code: 'ERR_FS_FILE_TOO_LARGE' } + // Do not include message: /^File size ([0-9]+ Kb) is greater than 2 GiB$/ +); +``` + ### Console output Output written by tests to stdout or stderr, such as with `console.log()` or |