Skip to content

Commit 3458936

Browse files
authored
test(examples): add isolatedModules: true test config (#1167)
1 parent 9eddb70 commit 3458936

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+272
-38
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const jestCfg = require('./jest-esm.config');
2+
3+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
4+
module.exports = {
5+
...jestCfg,
6+
globals: {
7+
'ts-jest': {
8+
tsconfig: '<rootDir>/tsconfig-esm.spec.json',
9+
stringifyContentPathRegex: '\\.(html|svg)$',
10+
isolatedModules: true,
11+
useESM: true,
12+
},
13+
},
14+
};

examples/example-app-v10/jest-esm.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor');
22
const { pathsToModuleNameMapper } = require('ts-jest/utils');
33
const { paths } = require('./tsconfig.json').compilerOptions;
44

5-
/** @type {import('@jest/types').Config.InitialOptions} */
5+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
66
module.exports = {
77
preset: 'jest-preset-angular/presets/defaults-esm',
88
globals: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const jestCfg = require('./jest.config');
2+
3+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
4+
module.exports = {
5+
...jestCfg,
6+
globals: {
7+
'ts-jest': {
8+
tsconfig: '<rootDir>/tsconfig.spec.json',
9+
stringifyContentPathRegex: '\\.(html|svg)$',
10+
isolatedModules: true,
11+
},
12+
},
13+
};

examples/example-app-v10/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor');
22
const { pathsToModuleNameMapper } = require('ts-jest/utils');
33
const { paths } = require('./tsconfig.json').compilerOptions;
44

5-
/** @type {import('@jest/types').Config.InitialOptions} */
5+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
66
module.exports = {
77
preset: 'jest-preset-angular',
88
moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '<rootDir>' }),

examples/example-app-v10/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
8-
"test": "jest",
9-
"test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js"
8+
"test": "jest --no-cache",
9+
"test-isolated": "jest -c=jest-isolated.config.js --no-cache",
10+
"test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js --no-cache",
11+
"test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache"
1012
},
1113
"private": true,
1214
"dependencies": {
@@ -32,4 +34,4 @@
3234
"jest-preset-angular": "^10.1.0",
3335
"typescript": "~4.0.7"
3436
}
35-
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const jestCfg = require('./jest-esm.config');
2+
3+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
4+
module.exports = {
5+
...jestCfg,
6+
globals: {
7+
'ts-jest': {
8+
tsconfig: '<rootDir>/tsconfig-esm.spec.json',
9+
stringifyContentPathRegex: '\\.(html|svg)$',
10+
isolatedModules: true,
11+
useESM: true,
12+
},
13+
},
14+
};

examples/example-app-v11/jest-esm.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor');
22
const { pathsToModuleNameMapper } = require('ts-jest/utils');
33
const { paths } = require('./tsconfig.json').compilerOptions;
44

5-
/** @type {import('@jest/types').Config.InitialOptions} */
5+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
66
module.exports = {
77
preset: 'jest-preset-angular/presets/defaults-esm',
88
globals: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const jestCfg = require('./jest.config');
2+
3+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
4+
module.exports = {
5+
...jestCfg,
6+
globals: {
7+
'ts-jest': {
8+
tsconfig: '<rootDir>/tsconfig.spec.json',
9+
stringifyContentPathRegex: '\\.(html|svg)$',
10+
isolatedModules: true,
11+
},
12+
},
13+
};

examples/example-app-v11/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('jest-preset-angular/ngcc-jest-processor');
22
const { pathsToModuleNameMapper } = require('ts-jest/utils');
33
const { paths } = require('./tsconfig.json').compilerOptions;
44

5-
/** @type {import('@jest/types').Config.InitialOptions} */
5+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
66
module.exports = {
77
preset: 'jest-preset-angular',
88
moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '<rootDir>' }),

examples/example-app-v11/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
8-
"test": "jest",
9-
"test-esm": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c=jest-esm.config.js"
8+
"test": "jest --no-cache",
9+
"test-isolated": "jest -c=jest-isolated.config.js --no-cache",
10+
"test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js --no-cache",
11+
"test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache"
1012
},
1113
"private": true,
1214
"dependencies": {
@@ -32,4 +34,4 @@
3234
"jest-preset-angular": "^10.1.0",
3335
"typescript": "~4.1.5"
3436
}
35-
}
37+
}

0 commit comments

Comments
 (0)