Please provide window.customElements to be able to test custom Web Components
See original GitHub issueI 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:
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
How to test custom web component with jest? - Stack Overflow
JSDOM 16.2 includes basic support for custom elements and is available in Jest 26.5 and above. Here's a simple Jest test that shows...
Read more >Window.customElements - Web APIs - MDN Web Docs
The customElements read-only property of the Window interface returns a reference to the CustomElementRegistry object, which can be used to ...
Read more >Web Components Test Drive - Medium
In this tutorial, we will build a web component that can be published ... Custom elements;; Templates;; Shadow DOM; and; ES modules (until ......
Read more >Custom Elements Everywhere
What's this? Custom Elements are the lynchpin in the Web Components specifications. They give developers the ability to define their own HTML elements....
Read more >Custom elements - The Modern JavaScript Tutorial
We can observe attributes by providing their list in observedAttributes() static getter. For such attributes, attributeChangedCallback is called ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
@awdltd you’ll need to use
jest-environment-jsdom-sixteen
untiljest@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
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 defaultThanks 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 👍