From 04817b55fd6d0f315baa9e97670f94f2d315796f Mon Sep 17 00:00:00 2001 From: ocavue Date: Wed, 31 Jul 2024 09:54:30 +1000 Subject: [PATCH] fix: fix jest-ts example (#76) --- with-jest-ts/jest.config.js | 13 ++++--------- with-jest-ts/package.json | 1 + with-jest-ts/tsconfig.json | 5 ++++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/with-jest-ts/jest.config.js b/with-jest-ts/jest.config.js index 4edef78..9fb18ca 100644 --- a/with-jest-ts/jest.config.js +++ b/with-jest-ts/jest.config.js @@ -1,3 +1,5 @@ +import { createDefaultPreset } from "ts-jest"; + /* * For a detailed explanation regarding each configuration property and type check, visit: * https://jestjs.io/docs/configuration @@ -11,14 +13,7 @@ const config = { extensionsToTreatAsEsm: [".ts", ".tsx"], - // https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ - preset: "ts-jest/presets/default-esm", - - globals: { - "ts-jest": { - useESM: true, - }, - }, + transform: { ...createDefaultPreset().transform }, }; -module.exports = config; +export default config; diff --git a/with-jest-ts/package.json b/with-jest-ts/package.json index a851ed5..77bc54b 100644 --- a/with-jest-ts/package.json +++ b/with-jest-ts/package.json @@ -2,6 +2,7 @@ "name": "with-jest-ts", "version": "1.0.0", "description": "", + "type": "module", "scripts": { "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, diff --git a/with-jest-ts/tsconfig.json b/with-jest-ts/tsconfig.json index 7b8d34f..1846ddc 100644 --- a/with-jest-ts/tsconfig.json +++ b/with-jest-ts/tsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { - "moduleResolution": "Node" + "module": "NodeNext", + "target": "ESNext", + "moduleResolution": "NodeNext", + "esModuleInterop": true } }