Comments (2)
Hi there! Thank you for the issue.
A wild guess here. It seems that in your case the ResizeObserver is already defined. A polyfill maybe? Another mock? The cannot redefine property
error would arise if the polyfill was applied, in such manner, for example:
Object.defineProperty(window, 'ResizeObserver', {
writable: true,
configurable: false,
value: PolyfilledResizeObserverClass,
});
Note the configurable: false
. In that case my code wouldn't be able to redefine it. Can you check if it's the case, please? I changed how I mock the ResizeObserver
class from basically:
window.ResizeObserver = MockedResizeObserver
to
Object.defineProperty(window, 'ResizeObserver', {
writable: true,
configurable: true,
value: MockedResizeObserver,
});
Because it is the recommended way, but maybe isn't the best.
Maybe you can disable the polyfill for tests somehow?
from jsdom-testing-mocks.
Will close this for now. Feel free to reopen if needed
from jsdom-testing-mocks.
Related Issues (8)
- Allow adding more properties to the IntersectionDescription HOT 5
- ResizeObserver should fire the onResize handler when ro.observe(elem) is called HOT 4
- Error with type-fest on build project HOT 2
- [Request] Add compatibility with other libraries HOT 8
- Animations aren't captured HOT 7
- `@media not all and ` is not supported HOT 1
- Do not require window at import time HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsdom-testing-mocks.