# Jest + Stencil + ESM

**URL:** <https://forum.ionicframework.com/t/jest-stencil-esm/242009>\
**Category:** Stencil\
**Created:** [May 24, 2024, 3:18pm UTC](https://forum.ionicframework.com/t/jest-stencil-esm/242009 "2024-05-24T15:18:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredppro](https://avatars.discourse-cdn.com/v4/letter/f/a88e57/32.png) [@fredppro](https://forum.ionicframework.com/u/fredppro)\
**Post date:** [May 24, 2024, 3:18pm UTC](https://forum.ionicframework.com/t/jest-stencil-esm/242009/1 "2024-05-24T15:18:04Z")

</div>

I need help configuring Jest in my stencil application. Currently i’m building a Design System in which i use:

1. Typescript;
2. Sholeace (a web component library);
3. 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

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 !
