Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests due to Node.js changing the JSON.parse error messages #635

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [12.20.0, 12.x, 14.x, 16.x, 18.x]
# macOS-13 is the latest macOS version that is x86.
# Node.js 12, 14 and 16 aren’t support on the arm64 runners.
os: [ubuntu-latest, macOS-13, windows-latest]
node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x]
# Also have a test on macOS arm64.
include:
- os: macOS-latest
node-version: 22.x

env:
ELM_HOME: '${{ github.workspace }}/elm-stuff/elm-home'
Expand Down
2 changes: 1 addition & 1 deletion elm-tooling.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"tools": {
"elm": "0.19.1",
"elm-format": "0.8.5",
"elm-json": "0.2.10"
"elm-json": "0.2.13"
}
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"elm-review": "2.9.1",
"elm-tooling": "1.10.0",
"elm-tooling": "1.15.1",
"eslint": "8.31.0",
"eslint-plugin-mocha": "10.1.0",
"flow-bin": "0.180.0",
Expand Down
12 changes: 10 additions & 2 deletions tests/ElmJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ describe('handling invalid elm.json', () => {
const elmJson = ElmJson.read(fullPath);
ElmJson.requireElmTestPackage(fullPath, elmJson);
},
{
message: expected,
(error) => {
assert.strictEqual(
error.message.replace(
// Handle slightly different JSON.parse error messages on different Node.js versions.
/^.+ in JSON at position .+$/gm,
'(the JSON parse error)'
),
expected
);
return true;
Comment on lines +47 to +56
Copy link

@lishaduck lishaduck Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass an assertion there 🤦‍♂️
Now that makes sense.

Copy link
Collaborator Author

@lydell lydell Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had to look that up the docs and play around with it in my editor. Otherwise I would have left a comment on your PR. Hope that’s ok 😄

This turned out to be difficult to merge anyway due to other things being out of date, and me trying to ambitious and not just do the simplest fix…

Copy link

@lishaduck lishaduck Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had to look that up the docs and play around with it in my editor. Otherwise I would have left a comment on your PR. Hope that’s ok 😄

That's fine 😁

This turned out to be difficult to merge anyway due to other things being out of date, and me trying to ambitious not just do the simplest fix…

I'd be the same way 😅

}
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/full/path/to/elm.json
Failed to read elm.json:
Unexpected string in JSON at position 11
(the JSON parse error)
Loading