I want to write a unit test with Jest, with jest-dom as a mock DOM--without having to transpile. I was hoping all I had to do was import the jest-dom package with a CommonJS import. But when I do that, then run my tests (with npm test
), it still fails with:
ReferenceError: document is not defined
(full output here)
Any ideas how to resolve this? My test file is below.
Thanks.
My Code
myApp.test.js
require("@testing-library/jest-dom");
document.createElement("div");