#54735: test: run spawned Electron apps with a timeout instead of spawnSync
Description of Change
Run the Electron apps that specs start with spawnSync() through spawnAndWait() instead, with a timeout.
spawnSync() blocks the spec worker's event loop until the app exits.
If the app hangs, the test's own timeout can't fire either, so nothing fails or reports until the whole run is killed.
Most of these call sites also ignored the app's exit status.
spawnAndWait() with a 20 second timeout kills a hung app and fails the test with the app's output.
Each test now also checks that the app exits with code 0, which all of these fixtures do on success.
Changed tests:
node.spec.ts: "Can find a module using a package.json main field"api-protocol.spec.ts: "throws for invalid scheme names", and the custom protocol code cache testsapi-app.spec.ts: thesetPath()session data testsmodules.spec.ts: "can be required if electron.exe is renamed" (Windows only)
Only test code changes.
Validation
Ran on a local Linux testing build of main under Xvfb:
- The 7 changed tests that run on Linux passed in each of 3 runs.
script/lint.js --jsandtsc -p tsconfig.spec.jsonpass.
🤖 Generated with Claude Code
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: none
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron