]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(test): investigate Windows CI hang (#1694)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 1 Mar 2026 12:23:57 +0000 (13:23 +0100)
committerGitHub <noreply@github.com>
Sun, 1 Mar 2026 12:23:57 +0000 (13:23 +0100)
commitaf75694d3f9b9cd1fea78573c4db424f14a319d5
treea728313ef0edaa4807b313c4e5f661729ebd6032
parent6a1c87c1daa3ba8efc935eb4e05362965a288f2b
fix(test): investigate Windows CI hang (#1694)

* fix(test): add --test-force-exit to prevent Windows CI hang

Windows CI was hanging after test completion due to Node.js's handling of
stdout/stderr on Windows. On Windows, stdio uses Named Pipes (Sockets) that
remain 'ref'd' and keep the event loop alive, unlike Unix where file
descriptors are auto-unref'd.

The --test-force-exit flag is the official Node.js solution for this
Windows-specific behavior (see Node.js issue #49925).

Also fixes:
- createMockAuthorizationResult signature to accept only overrides parameter
- Remove setImmediate from mock.timers in Reset test (not needed)

* fix(test): wrap multiple describe blocks in parent for --test-force-exit compatibility

Node.js test runner with --test-force-exit has issues with multiple top-level
await describe() blocks. Wrapping both 'Error Recovery and Resilience' and
'Message Buffering' describe blocks in a parent 'ChargingStation Resilience'
describe block fixes the 'Promise resolution is still pending' errors.

* fix(test): wrap OCPP20 test describe blocks for --test-force-exit compatibility

Same fix as ChargingStation-Resilience.test.ts - wrapping multiple top-level
await describe() blocks in a parent describe block to fix Windows CI hang.

* fix(tests): add missing deleteIdTags method to MockIdTagsCache

The MockIdTagsCache mock was missing the deleteIdTags() method that exists
on the real IdTagsCache class. This caused ClearCache tests to fail when
the method was called during test execution.

* fix(tests): improve test isolation for OCPP 2.0 tests

- Add ocppConfiguration with configurationKey to GetBaseReport test setup
  so ConfigurationInventory reports have data to return
- Add ocppConfiguration with HeartbeatInterval and WebSocketPingInterval
  to VariableManager test setup for proper isolation
- Fix MessageTimeout test expectations to use seconds (OCPP 2.0 unit)
  instead of milliseconds (station.getConnectionTimeout())

These changes ensure tests pass when run individually or in any order,
which is required for --test-force-exit on Windows.

* refactor(tests): use constants instead of hardcoded values in GetBaseReport test

Replace hardcoded '60' and '30' values with proper constant references:
- HeartbeatInterval: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL)
- MeterValueSampleInterval: millisecondsToSeconds(Constants.DEFAULT_METER_VALUES_INTERVAL)

This follows the single source of truth principle from TEST_STYLE_GUIDE.md
and maintains consistency with OCPP20VariableManager.test.ts.

* docs(tests): document Windows CI constraints and --test-force-exit

Add section 5 'Platform-Specific Considerations' to TEST_STYLE_GUIDE.md:
- Explain why --test-force-exit is needed (Windows Named Pipes behavior)
- Document single top-level describe block requirement
- Update section numbers and summary accordingly

This documents the root cause and solution for the Windows CI hang issue.
package.json
tests/TEST_STYLE_GUIDE.md
tests/charging-station/ChargingStation-Resilience.test.ts
tests/charging-station/mocks/MockCaches.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts
tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts
tests/charging-station/ocpp/auth/helpers/MockFactories.ts