Testing native js web components
summary
Shows how to test native JavaScript web components without a browser by mocking the DOM: jsdom lacks web components support so the solution treats window as an injected third‑party, supplying it via webpack externals, rollup globals or a window.mjs shim. Builds a minimal mock: attachShadow sets shadowRoot to a div and a tiny customElements registry that gets defined then frozen so tests cannot mutate it. Includes runnable examples for Jasmine, Mocha, and Jest with webpack, Rollup and ESM.
AI-written summary · about
chapters (7)
related talks
37mSay No(de) to the Browser: Testing your Webapp Frontend Code Using Just Node
36mThe Road to Native Web Components
42mWorking in the Shadow (DOM) - How to test Web Components
32mLet's talk about Web Components
17mThe jsdom
29mInspector Web and the Mystery of the Shadow DOM
38mCustom Elements Everywhere
31mNative Web Components - All Frameworks Invited
