Skip to content

Commit

Permalink
doc: clarify guide on testing internal errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
LiviaMedeiros authored and juanarbol committed May 31, 2022
1 parent eca030d commit 20acb48
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/contributing/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 20acb48

Please sign in to comment.