ReferenceError: PointerEvent is not defined
See original GitHub issueIssue :
After upgrading to Jest 24, I get this Typescript error:
ReferenceError: PointerEvent is not defined
I use a tsconfig.spec.json
(which seems to be loaded by ts-jest) which contains "lib": ["es2017", "dom"]
in compilerOptions
.
Expected behavior :
I expect PointerEvent
to be defined, as it is part of the TypeScript dom
lib.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:11 (5 by maintainers)
Top Results From Across the Web
javascript - How to substitute the PointerEvent in Jest ...
If I test this setup with jest it always throws me the error ReferenceError: PointerEvent is not defined . I can fix this...
Read more >Solution for “Error: The argument type 'PointerEvent' can't be ...
Solution for “Error: The argument type 'PointerEvent' can't be assigned to the ... Solution for “ReferenceError: util$4 is not defined” for Svelte apps....
Read more >PointerEvent - Web APIs | MDN
Chrome Edge
PointerEvent Full support. Chrome55. Toggle history Full support. Edge12. T...
PointerEvent() constructor Full support. Chrome55. Toggle history Full support. Edge12. T...
altitudeAngle. Experimental Full...
Read more >ReferenceError: PointerEvent is not defined - - Bountysource
ReferenceError : PointerEvent is not defined. I use a tsconfig.spec.json (which seems to be loaded by ts-jest) which contains "lib": ...
Read more >How to Fix ReferenceError: Event is Not Defined in JavaScript
JavaScript's ReferenceError: Event is Not Defined occurs if the event parameter is not declared correctly when using an event handler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I realized, this is not in jest’s hands. Jest uses JSDOM to run the tests, and after a quick check I saw there is already an issue opened in JSDOM to implement
PointerEvent
.Basically the Constructor is missing:
window.PointerEvent
.I suggest everyone interested in this to subscribe to this issue or even provide a PR to JSDOM: https://github.com/jsdom/jsdom/issues/2527
Once this is implemented in jsdom, it might take some additional time for jest to provide the test environment.
Until then this patching can be used:
It has to be registered in
jest.config.js
@ahnpnl I think this issue can be closed, there is nothing
ts-jest
can do about it.Summarizing the discussion in https://github.com/thymikee/jest-preset-angular/issues/245:
PointerEvent
in the method signature will throw this errortsconfig.spec.json
is configured with"types": ["dom"]
Minimal reproduction: