jest+jsdom: Test fails with TypeError parameter 1 is not of type 'Event'

Viewed 98

I have the following code being called from inside my test.

update(subject: ISubject, data?: any): void {
        let current = this.entries$.get(data.name)
        let element = this.elements$.get(data.name)
        if (data.button == "ok") {
            this.entries$.set(data.name, !current)
        }
        if (data.button == "cancel") {
            if (element) {
                let changeEvent: Event= new Event("change", { bubbles: true, cancelable: true  })
                element.dispatchEvent(changeEvent)
            }
        }
    }

I've debugged the code and at some point JSDOM verifies the argument to dispatchEvent and launches an exception. Is there any workaround for this?

0 Answers
Related