diff --git a/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.mjs b/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.ts b/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-monorepo/apps/app1/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/apps/app1/jest-esm.config.mjs b/examples/example-app-monorepo/apps/app1/jest-esm.config.mjs deleted file mode 100644 index 697b429291..0000000000 --- a/examples/example-app-monorepo/apps/app1/jest-esm.config.mjs +++ /dev/null @@ -1,27 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; -import { pathsToModuleNameMapper } from 'ts-jest'; -import tsconfig from './tsconfig.json' assert { type: 'json' }; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - displayName: 'app1', - moduleNameMapper: { - ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), - tslib: 'tslib/tslib.es6.js', - rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-monorepo/apps/app1/jest-esm.config.ts b/examples/example-app-monorepo/apps/app1/jest-esm.config.ts new file mode 100644 index 0000000000..ca7cd2ad37 --- /dev/null +++ b/examples/example-app-monorepo/apps/app1/jest-esm.config.ts @@ -0,0 +1,25 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { pathsToModuleNameMapper, type JestConfigWithTsJest } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + displayName: 'app1', + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/apps/app1/jest-isolated.config.js b/examples/example-app-monorepo/apps/app1/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-monorepo/apps/app1/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-monorepo/apps/app1/jest-isolated.config.ts b/examples/example-app-monorepo/apps/app1/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-monorepo/apps/app1/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/apps/app1/jest.config.js b/examples/example-app-monorepo/apps/app1/jest.config.js deleted file mode 100644 index c6fb09254e..0000000000 --- a/examples/example-app-monorepo/apps/app1/jest.config.js +++ /dev/null @@ -1,11 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - displayName: 'app1', - preset: 'jest-preset-angular', - setupFilesAfterEnv: ['/setup-jest.ts'], - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), -}; diff --git a/examples/example-app-monorepo/apps/app1/jest.config.ts b/examples/example-app-monorepo/apps/app1/jest.config.ts new file mode 100644 index 0000000000..b37361dbc5 --- /dev/null +++ b/examples/example-app-monorepo/apps/app1/jest.config.ts @@ -0,0 +1,10 @@ +import { pathsToModuleNameMapper, type JestConfigWithTsJest } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + displayName: 'app1', + preset: 'jest-preset-angular', + setupFilesAfterEnv: ['/setup-jest.ts'], + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/apps/app1/tsconfig.json b/examples/example-app-monorepo/apps/app1/tsconfig.json index 268b4e2447..fc83fb6d2f 100644 --- a/examples/example-app-monorepo/apps/app1/tsconfig.json +++ b/examples/example-app-monorepo/apps/app1/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig-base.json", + "extends": "../../tsconfig.json", "compilerOptions": { "baseUrl": "./", "paths": { diff --git a/examples/example-app-monorepo/jest-esm-isolated.config.mjs b/examples/example-app-monorepo/jest-esm-isolated.config.mjs deleted file mode 100644 index 61e25a2a6c..0000000000 --- a/examples/example-app-monorepo/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - projects: ['/apps/app1/jest-esm-isolated.config.mjs', '/libs/user/jest-esm-isolated.config.mjs'], -}; - -export default jestConfig; diff --git a/examples/example-app-monorepo/jest-esm-isolated.config.ts b/examples/example-app-monorepo/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..9214d3d0b4 --- /dev/null +++ b/examples/example-app-monorepo/jest-esm-isolated.config.ts @@ -0,0 +1,5 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { + projects: ['/apps/app1/jest-esm-isolated.config.ts', '/libs/user/jest-esm-isolated.config.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/jest-esm.config.mjs b/examples/example-app-monorepo/jest-esm.config.mjs deleted file mode 100644 index f80ed7b173..0000000000 --- a/examples/example-app-monorepo/jest-esm.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - projects: ['/apps/app1/jest-esm.config.mjs', '/libs/user/jest-esm.config.mjs'], -}; - -export default jestConfig; diff --git a/examples/example-app-monorepo/jest-esm.config.ts b/examples/example-app-monorepo/jest-esm.config.ts new file mode 100644 index 0000000000..6fe6e888cc --- /dev/null +++ b/examples/example-app-monorepo/jest-esm.config.ts @@ -0,0 +1,5 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { + projects: ['/apps/app1/jest-esm.config.ts', '/libs/user/jest-esm.config.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/jest-isolated.config.js b/examples/example-app-monorepo/jest-isolated.config.js deleted file mode 100644 index 42787f3fb7..0000000000 --- a/examples/example-app-monorepo/jest-isolated.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - projects: ['/apps/app1/jest-isolated.config.js', '/libs/user/jest-isolated.config.js'], -}; diff --git a/examples/example-app-monorepo/jest-isolated.config.ts b/examples/example-app-monorepo/jest-isolated.config.ts new file mode 100644 index 0000000000..41314359b8 --- /dev/null +++ b/examples/example-app-monorepo/jest-isolated.config.ts @@ -0,0 +1,5 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { + projects: ['/apps/app1/jest-isolated.config.ts', '/libs/user/jest-isolated.config.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/jest.config.js b/examples/example-app-monorepo/jest.config.js deleted file mode 100644 index 1e1bdc5efb..0000000000 --- a/examples/example-app-monorepo/jest.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - projects: ['/apps/app1', '/libs/user'], -}; diff --git a/examples/example-app-monorepo/jest.config.ts b/examples/example-app-monorepo/jest.config.ts new file mode 100644 index 0000000000..cc94c0f0fb --- /dev/null +++ b/examples/example-app-monorepo/jest.config.ts @@ -0,0 +1,5 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { + projects: ['/apps/app1', '/libs/user'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.mjs b/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.ts b/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-monorepo/libs/user/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/libs/user/jest-esm.config.mjs b/examples/example-app-monorepo/libs/user/jest-esm.config.mjs deleted file mode 100644 index f8f9fe3c20..0000000000 --- a/examples/example-app-monorepo/libs/user/jest-esm.config.mjs +++ /dev/null @@ -1,24 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - displayName: 'user-lib', - moduleNameMapper: { - tslib: 'tslib/tslib.es6.js', - rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-monorepo/libs/user/jest-esm.config.ts b/examples/example-app-monorepo/libs/user/jest-esm.config.ts new file mode 100644 index 0000000000..bc502bc14f --- /dev/null +++ b/examples/example-app-monorepo/libs/user/jest-esm.config.ts @@ -0,0 +1,22 @@ +import ngPreset from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { + ...ngPreset.defaultsESM, + displayName: 'user-lib', + moduleNameMapper: { + tslib: 'tslib/tslib.es6.js', + rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/libs/user/jest-isolated.config.ts b/examples/example-app-monorepo/libs/user/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-monorepo/libs/user/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/libs/user/jest.config.js b/examples/example-app-monorepo/libs/user/jest.config.ts similarity index 53% rename from examples/example-app-monorepo/libs/user/jest.config.js rename to examples/example-app-monorepo/libs/user/jest.config.ts index 6fbc3b25a8..fb921bc7a6 100644 --- a/examples/example-app-monorepo/libs/user/jest.config.js +++ b/examples/example-app-monorepo/libs/user/jest.config.ts @@ -1,6 +1,7 @@ -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { +import type { JestConfigWithTsJest } from 'ts-jest'; + +export default { displayName: 'user-lib', preset: 'jest-preset-angular', setupFilesAfterEnv: ['/setup-jest.ts'], -}; +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-monorepo/libs/user/tsconfig.lib.json b/examples/example-app-monorepo/libs/user/tsconfig.lib.json index 7e0d62a68d..b77b13c010 100644 --- a/examples/example-app-monorepo/libs/user/tsconfig.lib.json +++ b/examples/example-app-monorepo/libs/user/tsconfig.lib.json @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "../../tsconfig-base.json", + "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", "declaration": true, diff --git a/examples/example-app-monorepo/libs/user/tsconfig.spec.json b/examples/example-app-monorepo/libs/user/tsconfig.spec.json index 31927a64bd..40c21ee8af 100644 --- a/examples/example-app-monorepo/libs/user/tsconfig.spec.json +++ b/examples/example-app-monorepo/libs/user/tsconfig.spec.json @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "../../tsconfig-base.json", + "extends": "../../tsconfig.json", "compilerOptions": { "module": "CommonJS", "types": [ diff --git a/examples/example-app-monorepo/package.json b/examples/example-app-monorepo/package.json index 41eac8e928..257d541630 100644 --- a/examples/example-app-monorepo/package.json +++ b/examples/example-app-monorepo/package.json @@ -6,9 +6,9 @@ "start": "ng serve", "build": "ng build", "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "private": true, "dependencies": { diff --git a/examples/example-app-monorepo/tsconfig-base.json b/examples/example-app-monorepo/tsconfig.json similarity index 100% rename from examples/example-app-monorepo/tsconfig-base.json rename to examples/example-app-monorepo/tsconfig.json diff --git a/examples/example-app-v16/jest-esm-isolated.config.mjs b/examples/example-app-v16/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-v16/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-v16/jest-esm-isolated.config.ts b/examples/example-app-v16/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-v16/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v16/jest-esm.config.mjs b/examples/example-app-v16/jest-esm.config.mjs deleted file mode 100644 index c838df5dde..0000000000 --- a/examples/example-app-v16/jest-esm.config.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; -import { pathsToModuleNameMapper } from 'ts-jest'; -import tsconfig from './tsconfig.json' assert { type: 'json' }; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - moduleNameMapper: { - ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), - tslib: 'tslib/tslib.es6.js', - rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-v16/jest-esm.config.ts b/examples/example-app-v16/jest-esm.config.ts new file mode 100644 index 0000000000..6d52a9f885 --- /dev/null +++ b/examples/example-app-v16/jest-esm.config.ts @@ -0,0 +1,24 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v16/jest-isolated.config.js b/examples/example-app-v16/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-v16/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-monorepo/libs/user/jest-isolated.config.js b/examples/example-app-v16/jest-isolated.config.ts similarity index 63% rename from examples/example-app-monorepo/libs/user/jest-isolated.config.js rename to examples/example-app-v16/jest-isolated.config.ts index 19cc6d10ff..c90f9b152c 100644 --- a/examples/example-app-monorepo/libs/user/jest-isolated.config.js +++ b/examples/example-app-v16/jest-isolated.config.ts @@ -1,6 +1,6 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); +import presets from 'jest-preset-angular/presets'; -const jestCfg = require('./jest.config'); +import jestCfg from './jest.config'; /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ module.exports = { @@ -9,7 +9,7 @@ module.exports = { '^.+\\.(ts|js|mjs|html|svg)$': [ 'jest-preset-angular', { - ...defaultTransformerOptions, + ...presets.defaultTransformerOptions, isolatedModules: true, }, ], diff --git a/examples/example-app-v16/jest.config.js b/examples/example-app-v16/jest.config.js deleted file mode 100644 index 2c51a78ceb..0000000000 --- a/examples/example-app-v16/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - preset: 'jest-preset-angular', - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), - setupFilesAfterEnv: ['/setup-jest.ts'], -}; diff --git a/examples/example-app-v16/jest.config.ts b/examples/example-app-v16/jest.config.ts new file mode 100644 index 0000000000..35af6cf10e --- /dev/null +++ b/examples/example-app-v16/jest.config.ts @@ -0,0 +1,9 @@ +import { pathsToModuleNameMapper, type JestConfigWithTsJest } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + preset: 'jest-preset-angular', + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), + setupFilesAfterEnv: ['/setup-jest.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v16/package.json b/examples/example-app-v16/package.json index 5419117a57..d6d31bc7f5 100644 --- a/examples/example-app-v16/package.json +++ b/examples/example-app-v16/package.json @@ -6,9 +6,9 @@ "start": "ng serve", "build": "ng build", "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "private": true, "dependencies": { diff --git a/examples/example-app-v17/jest-esm-isolated.config.mjs b/examples/example-app-v17/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-v17/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-v17/jest-esm-isolated.config.ts b/examples/example-app-v17/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-v17/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v17/jest-esm.config.mjs b/examples/example-app-v17/jest-esm.config.mjs deleted file mode 100644 index c838df5dde..0000000000 --- a/examples/example-app-v17/jest-esm.config.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; -import { pathsToModuleNameMapper } from 'ts-jest'; -import tsconfig from './tsconfig.json' assert { type: 'json' }; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - moduleNameMapper: { - ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), - tslib: 'tslib/tslib.es6.js', - rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-v17/jest-esm.config.ts b/examples/example-app-v17/jest-esm.config.ts new file mode 100644 index 0000000000..6d52a9f885 --- /dev/null +++ b/examples/example-app-v17/jest-esm.config.ts @@ -0,0 +1,24 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v17/jest-isolated.config.js b/examples/example-app-v17/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-v17/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-v17/jest-isolated.config.ts b/examples/example-app-v17/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-v17/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v17/jest.config.js b/examples/example-app-v17/jest.config.js deleted file mode 100644 index 2c51a78ceb..0000000000 --- a/examples/example-app-v17/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - preset: 'jest-preset-angular', - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), - setupFilesAfterEnv: ['/setup-jest.ts'], -}; diff --git a/examples/example-app-v17/jest.config.ts b/examples/example-app-v17/jest.config.ts new file mode 100644 index 0000000000..5e8ab9cb78 --- /dev/null +++ b/examples/example-app-v17/jest.config.ts @@ -0,0 +1,9 @@ +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + preset: 'jest-preset-angular', + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), + setupFilesAfterEnv: ['/setup-jest.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v17/package.json b/examples/example-app-v17/package.json index e70176994f..7b5de52f30 100644 --- a/examples/example-app-v17/package.json +++ b/examples/example-app-v17/package.json @@ -6,9 +6,9 @@ "start": "ng serve", "build": "ng build", "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "private": true, "dependencies": { diff --git a/examples/example-app-v18/jest-esm-isolated.config.mjs b/examples/example-app-v18/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-v18/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-v18/jest-esm-isolated.config.ts b/examples/example-app-v18/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-v18/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v18/jest-esm.config.mjs b/examples/example-app-v18/jest-esm.config.mjs deleted file mode 100644 index c838df5dde..0000000000 --- a/examples/example-app-v18/jest-esm.config.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; -import { pathsToModuleNameMapper } from 'ts-jest'; -import tsconfig from './tsconfig.json' assert { type: 'json' }; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - moduleNameMapper: { - ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), - tslib: 'tslib/tslib.es6.js', - rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-v18/jest-esm.config.ts b/examples/example-app-v18/jest-esm.config.ts new file mode 100644 index 0000000000..6d52a9f885 --- /dev/null +++ b/examples/example-app-v18/jest-esm.config.ts @@ -0,0 +1,24 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v18/jest-isolated.config.js b/examples/example-app-v18/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-v18/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-v18/jest-isolated.config.ts b/examples/example-app-v18/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-v18/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v18/jest.config.js b/examples/example-app-v18/jest.config.js deleted file mode 100644 index 2c51a78ceb..0000000000 --- a/examples/example-app-v18/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - preset: 'jest-preset-angular', - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), - setupFilesAfterEnv: ['/setup-jest.ts'], -}; diff --git a/examples/example-app-v18/jest.config.ts b/examples/example-app-v18/jest.config.ts new file mode 100644 index 0000000000..5e8ab9cb78 --- /dev/null +++ b/examples/example-app-v18/jest.config.ts @@ -0,0 +1,9 @@ +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + preset: 'jest-preset-angular', + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), + setupFilesAfterEnv: ['/setup-jest.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-v18/package.json b/examples/example-app-v18/package.json index 10992ca02d..b523cac7a2 100644 --- a/examples/example-app-v18/package.json +++ b/examples/example-app-v18/package.json @@ -6,9 +6,9 @@ "start": "ng serve", "build": "ng build", "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "private": true, "dependencies": { diff --git a/examples/example-app-yarn-workspace/package.json b/examples/example-app-yarn-workspace/package.json index af9e234fac..8122b9b244 100644 --- a/examples/example-app-yarn-workspace/package.json +++ b/examples/example-app-yarn-workspace/package.json @@ -1,6 +1,6 @@ { "name": "example-app-yarn-workspace", - "version": "17.0.0", + "version": "18.0.0", "workspaces": { "packages": [ "packages/*" diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.mjs b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.ts b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.mjs b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.mjs deleted file mode 100644 index 08d7d9b975..0000000000 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; -import { pathsToModuleNameMapper } from 'ts-jest'; -import tsconfig from './tsconfig.json' assert { type: 'json' }; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - moduleNameMapper: { - ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), - tslib: 'tslib/tslib.es6.js', - rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.ts b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.ts new file mode 100644 index 0000000000..95996172a4 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.ts @@ -0,0 +1,24 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.js b/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.ts b/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest.config.js b/examples/example-app-yarn-workspace/packages/angular-app/jest.config.js deleted file mode 100644 index 2c51a78ceb..0000000000 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - preset: 'jest-preset-angular', - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), - setupFilesAfterEnv: ['/setup-jest.ts'], -}; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest.config.ts b/examples/example-app-yarn-workspace/packages/angular-app/jest.config.ts new file mode 100644 index 0000000000..5e8ab9cb78 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest.config.ts @@ -0,0 +1,9 @@ +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + preset: 'jest-preset-angular', + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), + setupFilesAfterEnv: ['/setup-jest.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/package.json b/examples/example-app-yarn-workspace/packages/angular-app/package.json index fe0c1ecdf5..5c9ccc2ce1 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/package.json +++ b/examples/example-app-yarn-workspace/packages/angular-app/package.json @@ -7,9 +7,9 @@ "start": "ng serve", "build": "ng build", "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "dependencies": { "@angular/animations": "^18.2.7", diff --git a/examples/example-app-yarn-workspace/packages/angular-app/tsconfig.json b/examples/example-app-yarn-workspace/packages/angular-app/tsconfig.json index 9395c55983..2bed27e807 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/tsconfig.json +++ b/examples/example-app-yarn-workspace/packages/angular-app/tsconfig.json @@ -14,6 +14,7 @@ "moduleResolution": "node", "importHelpers": true, "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, "esModuleInterop": true, "target": "ES2022", "module": "ES2022", diff --git a/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.mjs b/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.mjs deleted file mode 100644 index c0696cc27b..0000000000 --- a/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import jestCfg from './jest-esm.config.mjs'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestIsolatedCfg = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - isolatedModules: true, - useESM: true, - }, - ], - }, -}; - -export default jestIsolatedCfg; diff --git a/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.ts b/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.ts new file mode 100644 index 0000000000..1a63e299fd --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/user/jest-esm-isolated.config.ts @@ -0,0 +1,18 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest-esm.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/user/jest-esm.config.mjs b/examples/example-app-yarn-workspace/packages/user/jest-esm.config.mjs deleted file mode 100644 index dcc5d14ae0..0000000000 --- a/examples/example-app-yarn-workspace/packages/user/jest-esm.config.mjs +++ /dev/null @@ -1,23 +0,0 @@ -import ngPreset from 'jest-preset-angular/presets/index.js'; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const jestConfig = { - ...ngPreset.defaultsESM, - moduleNameMapper: { - tslib: 'tslib/tslib.es6.js', - rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', - }, - setupFilesAfterEnv: ['/setup-jest-esm.ts'], - transform: { - '^.+\\.(ts|js|html|svg)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig-esm.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - useESM: true, - }, - ], - }, -}; - -export default jestConfig; diff --git a/examples/example-app-yarn-workspace/packages/user/jest-esm.config.ts b/examples/example-app-yarn-workspace/packages/user/jest-esm.config.ts new file mode 100644 index 0000000000..95996172a4 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/user/jest-esm.config.ts @@ -0,0 +1,24 @@ +import ngPreset from 'jest-preset-angular/presets'; +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import tsconfig from './tsconfig.json'; + +export default { + ...ngPreset.defaultsESM, + moduleNameMapper: { + ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '' }), + tslib: 'tslib/tslib.es6.js', + rxjs: '/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', + }, + setupFilesAfterEnv: ['/setup-jest-esm.ts'], + transform: { + '^.+\\.(ts|js|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + useESM: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.js b/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.js deleted file mode 100644 index 19cc6d10ff..0000000000 --- a/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { defaultTransformerOptions } = require('jest-preset-angular/presets'); - -const jestCfg = require('./jest.config'); - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - ...jestCfg, - transform: { - '^.+\\.(ts|js|mjs|html|svg)$': [ - 'jest-preset-angular', - { - ...defaultTransformerOptions, - isolatedModules: true, - }, - ], - }, -}; diff --git a/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.ts b/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.ts new file mode 100644 index 0000000000..cfde54a067 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/user/jest-isolated.config.ts @@ -0,0 +1,17 @@ +import presets from 'jest-preset-angular/presets'; +import type { JestConfigWithTsJest } from 'ts-jest'; + +import jestCfg from './jest.config'; + +export default { + ...jestCfg, + transform: { + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + ...presets.defaultTransformerOptions, + isolatedModules: true, + }, + ], + }, +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/user/jest.config.js b/examples/example-app-yarn-workspace/packages/user/jest.config.js deleted file mode 100644 index 2c51a78ceb..0000000000 --- a/examples/example-app-yarn-workspace/packages/user/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const { pathsToModuleNameMapper } = require('ts-jest'); - -const { paths } = require('./tsconfig.json').compilerOptions; - -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -module.exports = { - preset: 'jest-preset-angular', - moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), - setupFilesAfterEnv: ['/setup-jest.ts'], -}; diff --git a/examples/example-app-yarn-workspace/packages/user/jest.config.ts b/examples/example-app-yarn-workspace/packages/user/jest.config.ts new file mode 100644 index 0000000000..5e8ab9cb78 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/user/jest.config.ts @@ -0,0 +1,9 @@ +import { type JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; + +export default { + preset: 'jest-preset-angular', + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '' }), + setupFilesAfterEnv: ['/setup-jest.ts'], +} satisfies JestConfigWithTsJest; diff --git a/examples/example-app-yarn-workspace/packages/user/package.json b/examples/example-app-yarn-workspace/packages/user/package.json index 531b0e7329..f727fee552 100644 --- a/examples/example-app-yarn-workspace/packages/user/package.json +++ b/examples/example-app-yarn-workspace/packages/user/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "test": "jest --no-cache", - "test-isolated": "jest -c=jest-isolated.config.js --no-cache", - "test-esm": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", - "test-esm-isolated": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" + "test-isolated": "jest -c=jest-isolated.config.ts --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm.config.ts --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.ts --no-cache" }, "devDependencies": { "@angular-devkit/build-angular": "^18.2.7", diff --git a/examples/example-app-yarn-workspace/packages/user/tsconfig.json b/examples/example-app-yarn-workspace/packages/user/tsconfig.json index 1a6203891d..8306a847f6 100644 --- a/examples/example-app-yarn-workspace/packages/user/tsconfig.json +++ b/examples/example-app-yarn-workspace/packages/user/tsconfig.json @@ -10,10 +10,13 @@ "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, - "target": "es2015", - "module": "es2020", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "target": "ES2022", + "module": "ES2022", "strict": true, - "lib": ["es2018", "dom"], + "lib": ["ES2022", "dom"], "paths": { "@shared/*": ["src/app/shared/*"] }