How do I test that a CustomEvent is dispatched in jasmine? When I try running the following code I get the error: "ReferenceError: Can't find variable: CustomEvent".
function testCustomEvent() {
window.dispatchEvent(new CustomEvent('myCustomEvent', {
detail: 'foo'
}));
}
describe('testCustomEvent', function() {
it('dispatches myCustomEvent', function() {
var eventSpy = jasmine.createSpy();
window.addEventListener('myCustomEvent', eventSpy);
testCustomEvent();
expect(eventSpy).toHaveBeenCalledWith('foo');
});
});