Fix Windows Node 24 CI test execution by using Jest JS entrypoint#77
Fix Windows Node 24 CI test execution by using Jest JS entrypoint#77
Conversation
Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/8dbfb95d-4191-4a0f-ad79-53f256035961 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
|
@copilot Games no longer load a start up. See attached images for errors. |
Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/b0b5b918-e702-48ea-9b0e-3b9a314be099 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
Fixed in commit |
|
@copilot Okay, you completely undid your changes. How do we solve the build problem that started this PR (in pasted image)? Start over, and try again. |
Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/74c2c103-b816-4c6a-beb4-49cc640ec2b8 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
You’re right. I restarted from the CI logs and fixed the actual Windows Node 24 failure in commit |
Release workflow failures on Windows (Node 24) were caused by how Jest was invoked in npm scripts, not by preload module format. This PR updates test script commands to use Jest’s JavaScript entrypoint directly so they run cross-platform, while preserving the existing preload runtime behavior that allows games to load at startup.
Cross-platform Jest invocation
package.jsonscripts:testtest:watchtest:coveragenode_modules/.bin/jest(Unix shell shim) tonode_modules/jest/bin/jest.js(direct Node entrypoint).Behavior preserved
Original prompt
Repo: acrosman/BrainSpeedExercises
Goal: Fix the failing GitHub Actions job in workflow
.github/workflows/release.yml(Release Build). The job fails on Windows in run https://github.com/acrosman/BrainSpeedExercises/actions/runs/24813101634/job/72621852346#step:5:24.Context:
"type": "module"in package.json).app/preload.jscurrently uses CommonJSrequire('electron'), which can fail when loaded as ESM under Node 22/24 in CI.app/preload.test.jswhich currently setsglobal.requireand then imports./preload.js.Implement the suggested fix:
Convert
app/preload.jsto proper ES module syntax:const { contextBridge, ipcRenderer } = require('electron');withimport { contextBridge, ipcRenderer } from 'electron';Update
app/preload.test.jsto mock the ESM import ofelectronusingjest.unstable_mockModule('electron', ...)before importing./preload.js.global.requiremocking and related cleanup.api.invokeand that allowed/blocked channels behave as expected.Keep changes minimal; do not downgrade Node. Node 22 or 24 must remain usable.
Ensure
npm testpasses.Notes:
Please open a PR with these changes.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The job is failing during the Node step (Windows runner) with a non-zero exit from a Node script, and you’re currently running on Node.js v24.15.0. The workflow is:
npm cinpm testnpm run publishGiven the log tail, the failure is happening inside a Node process (most likely
npm testornpm run publish) and is consistent with a Node 24 compatibility break (Node 24 is very new and commonly breaks older test runners, native addons, packaging scripts, and some Electron tooling).Fix (recommended): run the release workflow on Node 20 (LTS)
Change the workflow to use Node 20 instead of 24. This is the most reliable fix for CI/release pipelines unless you’ve explicitly validated Node 24 across your dependencies.
Edit
.github/workflows/release.ymlat ref0b6729158b27a039d18376414de8fe2fdf4167f8:Why this works:
Optional hardening (so it’s obvious which step fails)
Split the “publish” step to include more output and fail-fast context:
If you must support Node 24
Then you’ll need to upgrade the specific dependency/tool that is crashing under Node 24 (often a test runner, Electron/electron-builder, node-gyp native dependency, or a packaging script). But with the information available from the job log snippet, the actionable and safest solution is to pin CI to Node 20 LTS for the release workflow.
User: A previous version of the process used Node 20, and threw the same error. Also Node 20 leaves support in a few days. That's a poor solution. Node 22 or 24 must be used.
Assistant: The failure is coming from a CommonJS
require('electron')in an ES Module project. Yourpackage.jsonsets"type": "module", butapp/preload.jsis written as CommonJS:On Node 22/24 this commonly fails when the file is loaded as ESM (directly by tests, bundling, or tooling), producing a Node crash and exit code 1 (which matches the log tail you shared). This also explains why Node 20 showed the same error: it’s a module-type mismatch, not a Node-version-specific problem.
Solution: convert
app/preload.jsto ESM and update the test to mock ESM imports1) Update
app/preload.jsto use ESM import