Comments (5)
I had similar problem with jest
. A simple mock helped:
jest.mock('react-lazy-load', () => (props) => props.children)
However, I have no idea how this applies to other testing suites.
from react-lazy-load.
Hey I want to flag this issue again. I am working with version 3.0.12. I am using mocha and enzyme testing framework. I cannot execute my unit tests for the same reason reported here. The patch suggested by @raliasadil does not work.
from react-lazy-load.
Solution is the attached Patch
Subject: [PATCH] Fixes issue with HTMLElement
src/utils/parentScroll.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/utils/parentScroll.js b/src/utils/parentScroll.js
index e497941..4cfc154 100644
--- a/src/utils/parentScroll.js
+++ b/src/utils/parentScroll.js
@@ -3,6 +3,8 @@ const style = (element, prop) =>
? getComputedStyle(element, null).getPropertyValue(prop)
: element.style[prop];
+var HTMLElement = typeof HTMLElement === 'undefined' ? function(){} : HTMLElement;
+
const overflow = (element) =>
style(element, 'overflow') + style(element, 'overflow-y') + style(element, 'overflow-x');
2.8.1
from react-lazy-load.
@m8ms solution worked for me! Thanks!
https://jestjs.io/docs/en/mock-functions#mocking-modules
from react-lazy-load.
hello,
I'm having this same Issue I think, this is the complete log while trying to run test with jest.
"react": "^16.2.0",
"react-lazy-load": "^3.0.13",
`ReferenceError: HTMLElement is not defined
at scrollParent (node_modules/react-lazy-load/lib/utils/parentScroll.js:15:28)
at LazyLoad.getEventNode (node_modules/react-lazy-load/lib/LazyLoad.js:107:41)
at LazyLoad.componentDidMount (node_modules/react-lazy-load/lib/LazyLoad.js:71:28)
at commitLifeCycles (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:4553:24)
at commitAllLifeCycles (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5729:9)
at Object.invokeGuardedCallback$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:1559:10)
at invokeGuardedCallback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:1506:29)
at commitRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5833:9)
at performWorkOnRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6800:42)
at performWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6750:7)
`
Any progress on the matter ? thank you!!
from react-lazy-load.
Related Issues (20)
- Source code of 3.1.13 HOT 1
- Poor performance in Safari
- It loads me all the elements, how do I make it render as I scroll HOT 2
- Strict Mode compatibility HOT 2
- Should use componentDidUpdate instead of componentWillRecieveProps HOT 1
- NPM Installation Error in React@17+ HOT 5
- Does it work with next.js HOT 1
- load all items in chrome but lazyload visible item in firefox on page load HOT 1
- npm package is not latest HOT 1
- Use GH actions pipeline.
- Convert to functional with hooks
- Remove Lodash dependency HOT 1
- cant i use placeholder img till img load? HOT 2
- 4.0.0 was published with development dependencies in dependencies HOT 1
- .is-visible doesn't work well in loading.
- Support browsers without IntersectionObserver HOT 5
- Nothing triggers in Safari. HOT 4
- Rerendering Issue for Lazy Component:
- issue HOT 1
- Allow passing a root prop to IntersectionObserver
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 react-lazy-load.