I would like to test some custom web components. Chromium supports commands like
window.customElements.define('my-custom-element', MyCustomElementClass);
to register a custom web component.
However, window.customElements does not seem to be known in the context of jest tests.
=> Please allow to test custom web components directly with jest.
Also see related SO question:
This is a request to JSDOM, please send it there.
There is https://github.com/jsdom/jsdom/issues/1030 already (and PR: https://github.com/jsdom/jsdom/pull/2548)
I think that electron could include both node and chrome together.
so i found this, use electron to replace jsdom
https://github.com/facebook-atom/jest-electron-runner
The current version of jsDom running in Jest is v15.1.1. The latest release of jsDom (16.2.0) includes full support for customElements:
https://github.com/jsdom/jsdom/releases/tag/16.2.0
Any chance this issue be re-opened, and any ETA given for when Jest can bump the version?
@awdltd where did you find the latest jsdom version Jest uses? I know Jsdom is a dependency. Just unsure of where it is explicity declared.
@awdltd you'll need to use jest-environment-jsdom-sixteen until jest@26. Still a few months out I'd guess (haven't thought about it yet)
Hey @mkay581, I checked in my node_modules folder and jest-environment-jsdom is bundled with Jest (I admit I am taking liberties to assume that is what Jest uses by default). The package.json for this has "jsdom": "^15.1.1", so I assume that Jest will automatically use 15.. by default
Thanks for the heads up and the quick response, @SimenB! Fortunately found jest-environment-jsdom-sixteen in the interim and testing in that at the moment 馃憤
Most helpful comment
@awdltd you'll need to use
jest-environment-jsdom-sixteenuntiljest@26. Still a few months out I'd guess (haven't thought about it yet)@mkay581 https://github.com/facebook/jest/blob/1ed46e71a058c93b529e5e3f9388a800352de21a/packages/jest-environment-jsdom/package.json#L18