-
Notifications
You must be signed in to change notification settings - Fork 400
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 and other tweaks related to node 20 #2353
fix tests and other tweaks related to node 20 #2353
Conversation
The failing test was testing a failure caused by trying to parse an object as if it were a JSON string. It’s failing because the exception thrown by a JSON parse error changed between Node versions. Node 16.18.0 ============ ``` ==> node Welcome to Node.js v16.18.0. Type ".help" for more information. > JSON.parse("{") Uncaught SyntaxError: Unexpected end of JSON input > JSON.parse({}) Uncaught SyntaxError: Unexpected token o in JSON at position 1 ``` Node 20.11.1 ============ ``` ==> nvm use 20.11.1 Now using node v20.11.1 (npm v10.2.4) ==> node Welcome to Node.js v20.11.1. Type ".help" for more information. > JSON.parse({}) Uncaught SyntaxError: "[object Object]" is not valid JSON ```
You can get the integer from a javascript date with `.getTime()`
@@ -632,30 +636,19 @@ describe("graphql test suite", () => { | |||
typeof copiedCampaign.due_by === "number" || | |||
typeof copiedCampaign.due_by === "string" | |||
) { | |||
let parsedDate = new Date(copiedCampaign.due_by); | |||
const parsedDate = new Date(copiedCampaign.due_by); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To silence the linter.
if ( | ||
typeof copiedCampaign.features === "object" && | ||
copiedCampaign.features | ||
) { | ||
let jsonString = JSON.stringify(copiedCampaign.features); | ||
const jsonString = JSON.stringify(copiedCampaign.features); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To silence the linter.
…20 specified in package.json
0164840
to
8f4791e
Compare
@mau11 I think it's worth reviewing this and merging it if you approve. It gets the tests a lot further than before. I'll continue to work on the redis tests failing and make another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Larry 🎉 great fixes!
This looks great! |
e986194
into
StateVoicesNational:new-node-20-branch
This PR fixes a couple of failing tests.
Additional context in a slack thread.
Description
ERR_REQUIRE_ESM errors
Pinned
strip-ansi
to 6.0.1.Failing actions
actions/checkout@v3
toactions/checkout@v4
so it doesn't complain about node 20.actions/cache@v3
toactions/cache@v4
so it doesn't complain about node 20.Failure in
__test__/backend.test.js
Specify the campaign due date as milliseconds since the epoch when testing with SQLite.
I did a quick smoke test of copying a campaign in the UI when using SQLite and no additional special handling was necessary.
Failure in
__test__/extensions/action-handlers/ngpvan-action.test.js
The failing test was testing a failure caused by trying to parse an object as if it were a JSON string.
It’s failing because the exception thrown by a JSON parse error changed between Node versions.
Node 16.18.0
Node 20.11.1
Checklist: