From 19cf7ef19365d99c2f15af5fe5a5ad361bef8df9 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Thu, 21 Apr 2022 18:28:36 +0800 Subject: [PATCH 1/2] doc: clarify guide on testing internal errors --- doc/contributing/writing-tests.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index 6241cb68c9624f..b4bde96ea15a7e 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -312,6 +312,18 @@ assert.throws( ); ``` +In case of internal errors, prefer checking only `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 From 24d940724eda62ba9ebb14c69894fc18519c4acc Mon Sep 17 00:00:00 2001 From: Livia Medeiros <74449973+LiviaMedeiros@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:08:12 +0800 Subject: [PATCH 2/2] squash: add articles Co-authored-by: Colin Ihrig --- doc/contributing/writing-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index b4bde96ea15a7e..c24526f0139843 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -312,7 +312,7 @@ assert.throws( ); ``` -In case of internal errors, prefer checking only `code` property: +In the case of internal errors, prefer checking only the `code` property: ```js assert.throws(