From 467d99c516f2e8aaa0721691045979a9ab568158 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 4 Oct 2025 11:28:20 +0200 Subject: [PATCH] WIP:Chat-GPT --- jest.config.ts | 13 +++++++++---- package.json | 1 + setup-jest.ts | 3 ++- tsconfig.spec.json | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index cb97bddf..f795d6f2 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,17 +1,22 @@ import type { Config } from 'jest'; -export default { +const config: Config = { preset: 'jest-preset-angular', - setupFilesAfterEnv: ['/setup-jest.ts'], testEnvironment: 'jsdom', transform: { '^.+\\.(ts|mjs|js|html)$': [ 'ts-jest', { tsconfig: '/tsconfig.spec.json', + useESM: true, // 👈 Wichtig für Angular 20 + isolatedModules: true, stringifyContentPathRegex: '\\.html$', }, ], }, - moduleFileExtensions: ['ts', 'html', 'js', 'json'], -} satisfies Config; + extensionsToTreatAsEsm: ['.ts'], + moduleFileExtensions: ['ts', 'html', 'js', 'mjs', 'json'], + setupFilesAfterEnv: ['/setup-jest.ts'], +}; + +export default config; diff --git a/package.json b/package.json index 378b5d7e..15dc4cea 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "test": "jest", "test:watch": "jest --watch" }, + "type": "module", "prettier": { "printWidth": 100, "singleQuote": true, diff --git a/setup-jest.ts b/setup-jest.ts index 7197a78d..505888c7 100644 --- a/setup-jest.ts +++ b/setup-jest.ts @@ -1 +1,2 @@ -import 'jest-preset-angular/jest-preset'; +import 'jest-preset-angular/setup-env/zone'; +import 'jest-preset-angular/setup-env/globals'; diff --git a/tsconfig.spec.json b/tsconfig.spec.json index 9f8bf50a..cbc6a214 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -4,9 +4,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/spec", - "module": "commonjs", + "module": "ESNext", + "moduleResolution": "bundler", "esModuleInterop": true, - "target": "es2018", + "allowSyntheticDefaultImports": true, + "target": "ES2022", "types": [ "jest" ] -- 2.39.5