diff --git a/examples/example-app-v10/jest-esm-isolated.config.js b/examples/example-app-v10/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v10/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v10/jest-esm.config.js b/examples/example-app-v10/jest-esm.config.js index 4e1adbd875..46dfd04ac9 100644 --- a/examples/example-app-v10/jest-esm.config.js +++ b/examples/example-app-v10/jest-esm.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v10/jest-isolated.config.js b/examples/example-app-v10/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v10/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v10/jest.config.js b/examples/example-app-v10/jest.config.js index a52a8efecd..d3104738f2 100644 --- a/examples/example-app-v10/jest.config.js +++ b/examples/example-app-v10/jest.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), diff --git a/examples/example-app-v10/package.json b/examples/example-app-v10/package.json index 933118ec45..6c3bd30868 100644 --- a/examples/example-app-v10/package.json +++ b/examples/example-app-v10/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { @@ -32,4 +34,4 @@ "jest-preset-angular": "^10.1.0", "typescript": "~4.0.7" } -} \ No newline at end of file +} diff --git a/examples/example-app-v11/jest-esm-isolated.config.js b/examples/example-app-v11/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v11/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v11/jest-esm.config.js b/examples/example-app-v11/jest-esm.config.js index 4e1adbd875..46dfd04ac9 100644 --- a/examples/example-app-v11/jest-esm.config.js +++ b/examples/example-app-v11/jest-esm.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v11/jest-isolated.config.js b/examples/example-app-v11/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v11/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v11/jest.config.js b/examples/example-app-v11/jest.config.js index a52a8efecd..d3104738f2 100644 --- a/examples/example-app-v11/jest.config.js +++ b/examples/example-app-v11/jest.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), diff --git a/examples/example-app-v11/package.json b/examples/example-app-v11/package.json index 6ada86e9f3..20e97932f7 100644 --- a/examples/example-app-v11/package.json +++ b/examples/example-app-v11/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { @@ -32,4 +34,4 @@ "jest-preset-angular": "^10.1.0", "typescript": "~4.1.5" } -} \ No newline at end of file +} diff --git a/examples/example-app-v12-monorepo/jest-esm-isolated.config.js b/examples/example-app-v12-monorepo/jest-esm-isolated.config.js new file mode 100644 index 0000000000..ceeb3a9204 --- /dev/null +++ b/examples/example-app-v12-monorepo/jest-esm-isolated.config.js @@ -0,0 +1,7 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + projects: [ + '/projects/app1/jest-esm-isolated.config.js', + '/projects/app2/jest-esm-isolated.config.js', + ], +}; diff --git a/examples/example-app-v12-monorepo/jest-esm.config.js b/examples/example-app-v12-monorepo/jest-esm.config.js index 9d57ad456a..773fc4a44a 100644 --- a/examples/example-app-v12-monorepo/jest-esm.config.js +++ b/examples/example-app-v12-monorepo/jest-esm.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { projects: ['/projects/app1/jest-esm.config.js', '/projects/app2/jest-esm.config.js'], }; diff --git a/examples/example-app-v12-monorepo/jest-isolated.config.js b/examples/example-app-v12-monorepo/jest-isolated.config.js new file mode 100644 index 0000000000..9c1f408de1 --- /dev/null +++ b/examples/example-app-v12-monorepo/jest-isolated.config.js @@ -0,0 +1,4 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + projects: ['/projects/app1/jest-isolated.config.js', '/projects/app2/jest-isolated.config.js'], +}; diff --git a/examples/example-app-v12-monorepo/jest.config.js b/examples/example-app-v12-monorepo/jest.config.js index ad376e45e6..a927134368 100644 --- a/examples/example-app-v12-monorepo/jest.config.js +++ b/examples/example-app-v12-monorepo/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { projects: ['/projects/app1', '/projects/app2'], }; diff --git a/examples/example-app-v12-monorepo/package.json b/examples/example-app-v12-monorepo/package.json index ab420fc1af..106cc124f2 100644 --- a/examples/example-app-v12-monorepo/package.json +++ b/examples/example-app-v12-monorepo/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { @@ -32,4 +34,4 @@ "jest-preset-angular": "^10.1.0", "typescript": "~4.2.3" } -} \ No newline at end of file +} diff --git a/examples/example-app-v12-monorepo/projects/app1/jest-esm-isolated.config.js b/examples/example-app-v12-monorepo/projects/app1/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v12-monorepo/projects/app1/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v12-monorepo/projects/app1/jest-esm.config.js b/examples/example-app-v12-monorepo/projects/app1/jest-esm.config.js index a8c09f3479..7daf45bb7f 100644 --- a/examples/example-app-v12-monorepo/projects/app1/jest-esm.config.js +++ b/examples/example-app-v12-monorepo/projects/app1/jest-esm.config.js @@ -1,6 +1,6 @@ require('jest-preset-angular/ngcc-jest-processor'); -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v12-monorepo/projects/app1/jest-isolated.config.js b/examples/example-app-v12-monorepo/projects/app1/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v12-monorepo/projects/app1/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v12-monorepo/projects/app1/jest.config.js b/examples/example-app-v12-monorepo/projects/app1/jest.config.js index b02c7f5343..ef5df4e9ef 100644 --- a/examples/example-app-v12-monorepo/projects/app1/jest.config.js +++ b/examples/example-app-v12-monorepo/projects/app1/jest.config.js @@ -1,6 +1,6 @@ require('jest-preset-angular/ngcc-jest-processor'); -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: { diff --git a/examples/example-app-v12-monorepo/projects/app2/jest-esm-isolated.config.js b/examples/example-app-v12-monorepo/projects/app2/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v12-monorepo/projects/app2/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v12-monorepo/projects/app2/jest-esm.config.js b/examples/example-app-v12-monorepo/projects/app2/jest-esm.config.js index 576ecbde73..8f5527598a 100644 --- a/examples/example-app-v12-monorepo/projects/app2/jest-esm.config.js +++ b/examples/example-app-v12-monorepo/projects/app2/jest-esm.config.js @@ -1,6 +1,6 @@ require('jest-preset-angular/ngcc-jest-processor'); -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v12-monorepo/projects/app2/jest-isolated.config.js b/examples/example-app-v12-monorepo/projects/app2/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v12-monorepo/projects/app2/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v12-monorepo/projects/app2/jest.config.js b/examples/example-app-v12-monorepo/projects/app2/jest.config.js index e2dbce1398..60e19ac4cf 100644 --- a/examples/example-app-v12-monorepo/projects/app2/jest.config.js +++ b/examples/example-app-v12-monorepo/projects/app2/jest.config.js @@ -1,6 +1,6 @@ require('jest-preset-angular/ngcc-jest-processor'); -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: { diff --git a/examples/example-app-v12/jest-esm-isolated.config.js b/examples/example-app-v12/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v12/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v12/jest-esm.config.js b/examples/example-app-v12/jest-esm.config.js index 4e1adbd875..46dfd04ac9 100644 --- a/examples/example-app-v12/jest-esm.config.js +++ b/examples/example-app-v12/jest-esm.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v12/jest-isolated.config.js b/examples/example-app-v12/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v12/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v12/jest.config.js b/examples/example-app-v12/jest.config.js index a52a8efecd..d3104738f2 100644 --- a/examples/example-app-v12/jest.config.js +++ b/examples/example-app-v12/jest.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), diff --git a/examples/example-app-v12/package.json b/examples/example-app-v12/package.json index 12ef4dcc59..e13f2e5e25 100644 --- a/examples/example-app-v12/package.json +++ b/examples/example-app-v12/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { @@ -32,4 +34,4 @@ "jest-preset-angular": "^10.1.0", "typescript": "~4.2.4" } -} \ No newline at end of file +} diff --git a/examples/example-app-v13/jest-esm-isolated.config.js b/examples/example-app-v13/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-v13/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-v13/jest-esm.config.js b/examples/example-app-v13/jest-esm.config.js index 4e1adbd875..46dfd04ac9 100644 --- a/examples/example-app-v13/jest-esm.config.js +++ b/examples/example-app-v13/jest-esm.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { diff --git a/examples/example-app-v13/jest-isolated.config.js b/examples/example-app-v13/jest-isolated.config.js new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-v13/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; diff --git a/examples/example-app-v13/jest.config.js b/examples/example-app-v13/jest.config.js index a52a8efecd..d3104738f2 100644 --- a/examples/example-app-v13/jest.config.js +++ b/examples/example-app-v13/jest.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), diff --git a/examples/example-app-v13/package.json b/examples/example-app-v13/package.json index 4c4b8cbab2..075b930e9a 100644 --- a/examples/example-app-v13/package.json +++ b/examples/example-app-v13/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { diff --git a/examples/example-app-yarn-workspace/package.json b/examples/example-app-yarn-workspace/package.json index 20d716ad33..167dfe47ec 100644 --- a/examples/example-app-yarn-workspace/package.json +++ b/examples/example-app-yarn-workspace/package.json @@ -9,6 +9,8 @@ "private": true, "scripts": { "test": "yarn workspace angular-app test", - "test-esm": "yarn workspace angular-app test-esm" + "test-isolated": "yarn workspace angular-app test-isolated", + "test-esm": "yarn workspace angular-app test-esm", + "test-esm-isolated": "yarn workspace angular-app test-esm-isolated" } } diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.js b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2f68bd933a --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm-isolated.config.js @@ -0,0 +1,14 @@ +const jestCfg = require('./jest-esm.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig-esm.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + useESM: true, + }, + }, +}; diff --git a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.js b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.js index 4e1adbd875..46dfd04ac9 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.js +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-esm.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular/presets/defaults-esm', globals: { 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 new file mode 100644 index 0000000000..a77e374423 --- /dev/null +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest-isolated.config.js @@ -0,0 +1,13 @@ +const jestCfg = require('./jest.config'); + +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + ...jestCfg, + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + isolatedModules: true, + }, + }, +}; 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 index a52a8efecd..d3104738f2 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/jest.config.js +++ b/examples/example-app-yarn-workspace/packages/angular-app/jest.config.js @@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor'); const { pathsToModuleNameMapper } = require('ts-jest/utils'); const { paths } = require('./tsconfig.json').compilerOptions; -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'jest-preset-angular', moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '' }), 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 6ea58495d9..3bfe2e8ada 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/package.json +++ b/examples/example-app-yarn-workspace/packages/angular-app/package.json @@ -5,8 +5,10 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test": "jest", - "test-esm": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "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.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "private": true, "dependencies": { diff --git a/jest.config.js b/jest.config.js index 9de8e1b522..aa8b1c93e8 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/scripts/test-examples.js b/scripts/test-examples.js index 47bd6e45cb..7e130b36e3 100755 --- a/scripts/test-examples.js +++ b/scripts/test-examples.js @@ -36,10 +36,12 @@ const executeTest = (projectPath) => { }); // then we can run the tests - const cmdLine = ['yarn', 'test', '--no-cache']; - const cmdESMLine = ['yarn', 'test-esm', '--no-cache']; + const cmdLine = ['yarn', 'test']; + const cmdIsolatedLine = ['yarn', 'test-isolated']; + const cmdESMLine = ['yarn', 'test-esm']; + const cmdESMIsolatedLine = ['yarn', 'test-esm-isolated']; - logger.log('starting the CommonJS tests using:', ...cmdLine); + logger.log('starting the CommonJS tests with isolatedModules: false using:', ...cmdLine); logger.log(); execa.sync(cmdLine.shift(), cmdLine, { @@ -48,9 +50,18 @@ const executeTest = (projectPath) => { env: process.env, }); + logger.log('starting the CommonJS tests with isolatedModules: true using:', ...cmdIsolatedLine); + logger.log(); + + execa.sync(cmdIsolatedLine.shift(), cmdIsolatedLine, { + cwd: projectPath, + stdio: 'inherit', + env: process.env, + }); + // TODO: Enable when fully support ESM with Angular 13 if (!projectPkg.version.startsWith('13')) { - logger.log('starting the ESM tests using:', ...cmdESMLine); + logger.log('starting the ESM tests with isolatedModules: false using:', ...cmdESMLine); logger.log(); execa.sync(cmdESMLine.shift(), cmdESMLine, { @@ -58,6 +69,15 @@ const executeTest = (projectPath) => { stdio: 'inherit', env: process.env, }); + + logger.log('starting the ESM tests with isolatedModules: true using:', ...cmdESMIsolatedLine); + logger.log(); + + execa.sync(cmdESMIsolatedLine.shift(), cmdESMIsolatedLine, { + cwd: projectPath, + stdio: 'inherit', + env: process.env, + }); } };