Tests: Use real "Event" instead of mocking HistoryChange
Author: rugkCreated May 7, 2026Updated Jul 22, 2026
Labelsenhancementcode qualityjavascript
The problem
Apparently JSDom doe snot support HistoryChange events. It thus uses a mock function: https://github.com/PrivateBin/PrivateBin/blob/846476402fe933493d1edacc3f200b2343e3f57e/js/test/UiHelper.js#L22
It's generally a bad idea to have methods in your prod code just for mocking/testing purposes.
The solution
similar to how the Clipboard event is mocked/created (just as a custom Event that bubbles), this event should be similarly mockable, should not it?
Alternatives
Keep as is.
Additional context
Source: PrivateBin/PrivateBin