Skip to content

"SyntaxError: Cannot use import statement outside a module" running jest #70

@wuifdesign

Description

@wuifdesign
  • @testing-library/preact version: 3.2.3
  • preact version: 10.13.2
  • node version: 18.14.0
  • npm version: 9.3.1

What happened:

Starting with v3.1.0 i have problems running my tests with jest.

When running jest i get following error:

.../node_modules/@testing-library/preact/dist/esm/index.mjs:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { cleanup } from "./pure.mjs";
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module
// jest.config.js

const config = {
  testEnvironment: 'jsdom',
  transform: {
    '\\.[jt]sx?$': ['@swc/jest']
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions