Closed as not planned
Description
Version
v18.16.0
Platform
21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
global.window = jsdom.window as any;
How often does it reproduce? Is there a required condition?
Error is consistent. This error did not occur when using Node 18.15.0, and also does not occur when using Node 19.9.0.
What is the expected behavior? Why is that the expected behavior?
Expected behavior is no error.
What do you see instead?
TypeError: Cannot redefine property: window
Additional information
Same issue as: #47310
Similar to that issue, I've run into this error when running tests that use JSDom:
- Save the following as "test.js":
/**
* @jest-environment jsdom
*/
"use strict"
global.window = {};
describe("test", () => {
it("runs", () => {
expect(1 + 1).toEqual(2);
});
});
- Run
npm i jest jest-environment-jsdom
- Run
npx jest
Metadata
Metadata
Assignees
Labels
No labels