mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-10-25 04:55:06 +00:00
dev-test: JSDOM's Event and CustomEvent win over Node's in the browser env
Globals were only set where Node had none, and Node defines Event and CustomEvent itself. Code running in the browser env therefore built Node events, which a JSDOM node refuses: react-tooltip's window.dispatchEvent(new CustomEvent(...)) threw "parameter 1 is not of type 'Event'". In the browser env these two now come from JSDOM, as they do under jest-environment-jsdom.
This commit is contained in:
1 parent
1ba9b3e57f
commit
0cd4f12cfb
3 files changed
+21
-2
No files matched your search
+5
@@ -23,4 +23,9 @@ describe('browser', () => {
|
||||
it('contains HTML*Element', () => {
|
||||
expect(typeof all.HTMLElement).toBe('function');
|
||||
});
|
||||
|
||||
it('dispatches the global CustomEvent and Event on window', () => {
|
||||
expect(() => window.dispatchEvent(new CustomEvent('custom', { detail: 1 }))).not.toThrow();
|
||||
expect(() => window.dispatchEvent(new Event('plain'))).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user