mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
- Refactor `tests/nostr/videoEventBuffer.test.mjs` to safely restore `global.document` using try...finally. - Refactor `tests/ui/engagement-controller.test.mjs` to safely delete `global.window` using try...finally. - Fixes potential test pollution that could cause flakes in shared environments. Ran `npm run test:unit` for verification. Co-authored-by: PR0M3TH3AN <[email protected]>
990 B
990 B
CI Health Agent - Daily Run
Date: 2026-02-14 Agent: ci-health-agent Status: Completed
Summary
Identified and fixed test pollution risks in unit tests that mocked global objects (global.document and global.window) without guaranteed cleanup.
Changes
- Refactored
tests/nostr/videoEventBuffer.test.mjs: Wrappedglobal.documentmocking in atry...finallyblock to ensure restoration even if assertions fail. - Refactored
tests/ui/engagement-controller.test.mjs: Wrappedglobal.windowmocking in atry...finallyblock to ensure deletion even if assertions fail.
Verification
Ran the affected tests locally to ensure they pass:
tests/nostr/videoEventBuffer.test.mjs: Passedtests/ui/engagement-controller.test.mjs: Passed
Learnings
- Tests running in the same process (even sequentially) can pollute global state (
window,document) if not cleaned up properly. try...finallyis crucial when mocking globals in tests.