-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hello, I have created an EventSource in a file configJSDom.js:
import EventSource from 'eventsourcemock';
Object.defineProperty(window, 'EventSource', {
value: EventSource,
});
It was used by jest and in my test I add import { sources } from 'eventsourcemock'; and try to mock that:
new EventSource(Utils.apiUrl()+"/sse_stream", { withCredentials: true });
With that:
sources[Utils.apiUrl()+"/sse_stream"].emitOpen();
sources['http://example.com/events'].emit(
messageEvent.type,
messageEvent
);
But it crash with that:
TypeError: Cannot read property 'emitOpen' of undefined
138 | tree.instance().startEvent();
139 | expect(cookie.get("sse_loading")).toBe("true");
> 140 | sources[Utils.apiUrl()+"/sse_stream"].emitOpen();
| ^
141 | sources['http://example.com/events'].emit(
142 | messageEvent.type,
143 | messageEvent
at Object.emitOpen (src/__test__/Panel.test.js:140:41)
Have I forgot something ?
alang-dev, slutske22 and bluepioupiou
Metadata
Metadata
Assignees
Labels
No labels