Skip to content

Commit

Permalink
Merge pull request #77 from Rich-Harris/node-20
Browse files Browse the repository at this point in the history
add node 18/20 to test matrix, fix bad error in node 20
  • Loading branch information
Rich-Harris committed Apr 19, 2024
2 parents 50af63e + d67d05b commit 4ce76d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16]
node-version: [16, 18, 20]
os: [ubuntu-latest]
steps:
- run: git config --global core.autocrlf false
Expand Down
15 changes: 13 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Custom {
}
}

const node_version = +process.versions.node.split('.')[0];

const fixtures = {
basics: [
{
Expand Down Expand Up @@ -475,7 +477,10 @@ const invalid = [
{
name: 'invalid JSON',
json: '][',
message: 'Unexpected token ] in JSON at position 0'
message:
node_version >= 20
? `Unexpected token ']', "][" is not valid JSON`
: 'Unexpected token ] in JSON at position 0'
},
{
name: 'hole',
Expand Down Expand Up @@ -518,7 +523,13 @@ for (const { name, json, message } of invalid) {
uvu.test(`parse error: ${name}`, () => {
assert.throws(
() => parse(json),
(error) => error.message === message
(error) => {
const match = error.message === message;
if (!match) {
console.error(`Expected: ${message}, got: ${error.message}`);
}
return match;
}
);
});
}
Expand Down

0 comments on commit 4ce76d6

Please sign in to comment.