I\'m trying to write tests for my web components projects in jest. I already use babel with es2015 preset. I\'m facing an issue while loading the js file. I have followed a
Similar to what others have said, but instead of trying to mock the DOM yourself, just use JSDOM:
mocks/client.js
import { JSDOM } from "jsdom"
const dom = new JSDOM()
global.document = dom.window.document
global.window = dom.window
Then in your jest config:
"setupFiles": [
"./__mocks__/client.js"
],