Jest: SyntaxError: Cannot use import statement outside a module #7269
-
I'm trying to setup jest in my Next.js typescript app which uses ui5-webcomponents-react. But for testing components that is using ui5-webcomponent its failing.
Here is my package.json:
I saw that Jest does not support ECMAScript Modules (https://stackoverflow.com/a/75604417). So I was wondering if this could be the problem. I could try to build a minimal reproducible example but before I do that I wanted to ask if Jest is generally working with this library (and Next + typescript), if someone has a running Jest setup that they can share or if there are any work arounds for the error. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
testing (ui5) web components with JSDOM is generally discouraged mainly because:
For accurate and reliable testing of web components, it's recommended to use real or headless browser environments such as Cypress offers. Regarding your issue maybe this section of our V1 documentation helps (especially setting |
Beta Was this translation helpful? Give feedback.
Hi @philippkolbe
testing (ui5) web components with JSDOM is generally discouraged mainly because:
node
DOM emulator, not a full browser: It lacks many browser APIs (e.g.,ResizeObserver
,IntersectionObserver
,matchMedia
), requiring manual polyfills or mocks for testing web components.getBoundingClientRect
and media queries won't function as expected.For accurate and reli…