-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot redefine property: inert #8373
Comments
I created an issue on the inert package to only define the property if it hasn't been defined. I'm not sure if that's the solution for Jest tests or just something that couldn't hurt. |
The |
Reproduction without Jest: const { JSDOM } = require("jsdom");
const { window } = new JSDOM("");
function polyfill() {
Object.defineProperty(window.Element.prototype, "inert", {
enumerable: true,
get: function() {},
set: function() {}
});
}
polyfill();
polyfill(); Suboptimal that it seems the prototype leaks across tests... |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
When importing the WICG Inert Polyfill in a react component that we test with Jest, our Jest tests started failing with the following error message:
This seems to be triggered by the WICG Inert polyfill using Object.defineProperty on the Element prototype
I believe this is an issue with JSDOM but is manifesting when using Jest. I tried setting the
--no-cache
flag when running Jest to no avail.To Reproduce
I'm working on creating a repo to reproduce this issue.
This should be reproducible by creating a react component that imports WICG Inert Polyfill and then trying to test it with Jest.
Expected behavior
A way to use the inert polyfill with Jest is documented.
Link to repl or repo (highly encouraged)
I'm working on creating a repo to reproduce this issue and will post a link once I get the reduced test case put together.
Run
npx envinfo --preset jest
The text was updated successfully, but these errors were encountered: