I need help configuring Jest in my stencil application. Currently i’m building a Design System in which i use:
- Typescript;
- Sholeace (a web component library);
- Jest for unit testing.
Project structure (monorepo with npm workspaces only):
- design-system/
- node_modules (which contains the shoelace library)
- packages/
- stencil-app/
- stencil.config.ts
- tsconfig.json
- stencil-app/
- packages/
I implemented a wrapper component that imports the shoelace tooltip component, which is built as an ESM Module, so I imported via the @import statement.
My current problem is that my spec tests are failing because it says:
SyntaxError: Cannot use import statement outside a module
1 | import { Component, Prop, h } from '@stencil/core';
> 2 | import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
I’ve tried everything, using babel with jest, using ts-jest, using other presets of ts-jest… Creating separate configurations for babel and jest, although stencil provides the “testing” object for in stencil.config.ts
…
Nothing seems to work !