Skip to content

Commit 54e7b79

Browse files
authored
chore: fix tests error message assertions to pass while running Node.js 19 (#2616)
Closes #2564
1 parent 46cf5ed commit 54e7b79

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ references:
2727
nodejs_versions:
2828
- &nodejs_current "14.19"
2929
- &nodejs_next "16.14"
30-
- &nodejs_experimental "18.13"
30+
# nodejs 19.3 comes with npm 9.0, which breaks "npm config set python" below
31+
- &nodejs_experimental "19.2"
3132

3233
nodejs_enum: &nodejs_enum
3334
type: enum

tests/unit/test-cmd/test.build.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ describe('build', () => {
267267
.then(makeSureItFails())
268268
.catch((error) => {
269269
assert.instanceOf(error, UsageError);
270+
// Matching error messages from either Node.js < 19 or Node.js >= 19
271+
// Node.js 19.0 includes V8 10.7 [1], and the latter includes changes to make JSON.parse errors user-friendly
272+
// [1] https://github.com/nodejs/node/pull/44741
273+
// [2] https://chromium-review.googlesource.com/c/v8/v8/+/3513684
274+
// [3] https://chromium-review.googlesource.com/c/v8/v8/+/3652254
270275
assert.match(
271276
error.message,
272-
/Unexpected string in JSON at position 14/
277+
/Unexpected string in JSON at position 14|Expected ':' after property name in JSON at position 14/
273278
);
274279
assert.match(error.message, /^Error parsing messages\.json/);
275280
assert.include(error.message, messageFileName);

tests/unit/test-util/test.manifest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ describe('util/manifest', () => {
6868
error.message,
6969
/Error parsing manifest\.json file at /
7070
);
71-
assert.include(
71+
// Matching error messages from either Node.js < 19 or Node.js >= 19
72+
// See comments in tests/unit/test-cmd/test.build.js
73+
assert.match(
7274
error.message,
73-
'Unexpected token "," (0x2C) in JSON at position 51'
75+
/Unexpected token "," \(0x2C\) in JSON at position 51|Expected double-quoted property name in JSON at position 51/
7476
);
7577
assert.include(error.message, manifestFile);
7678
})

0 commit comments

Comments
 (0)