fix(testing): update ts-jest to version 26.5.5 (#5405)
Update `jest.config.js` ts-jest section with lower-cased 'tsconfig' property as 'tsConfig' is to be deprecated in version 27.
This commit is contained in:
parent
c41968648a
commit
357ecd09a4
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
transform: {
|
transform: {
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-angular',
|
displayName: 'e2e-angular',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-cli',
|
displayName: 'e2e-cli',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-cypress',
|
displayName: 'e2e-cypress',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-next',
|
displayName: 'e2e-next',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-jest',
|
displayName: 'e2e-jest',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-linter',
|
displayName: 'e2e-linter',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-next',
|
displayName: 'e2e-next',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-node',
|
displayName: 'e2e-node',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -387,7 +387,7 @@ describe('nest libraries', function () {
|
|||||||
preset: '../../jest.preset.js',
|
preset: '../../jest.preset.js',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-nx-plugin',
|
displayName: 'e2e-nx-plugin',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-react',
|
displayName: 'e2e-react',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-storybook',
|
displayName: 'e2e-storybook',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-web',
|
displayName: 'e2e-web',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'e2e-workspace',
|
displayName: 'e2e-workspace',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
displayName: 'nx-dev-data-access-documents',
|
displayName: 'nx-dev-data-access-documents',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
transform: {
|
transform: {
|
||||||
|
|||||||
@ -219,7 +219,7 @@
|
|||||||
"tippy.js": "^6.3.1",
|
"tippy.js": "^6.3.1",
|
||||||
"tmp": "~0.2.1",
|
"tmp": "~0.2.1",
|
||||||
"tree-kill": "1.2.2",
|
"tree-kill": "1.2.2",
|
||||||
"ts-jest": "26.4.0",
|
"ts-jest": "26.5.5",
|
||||||
"ts-loader": "5.4.5",
|
"ts-loader": "5.4.5",
|
||||||
"ts-node": "9.1.1",
|
"ts-node": "9.1.1",
|
||||||
"tsconfig-paths": "^3.9.0",
|
"tsconfig-paths": "^3.9.0",
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'angular',
|
displayName: 'angular',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'cli',
|
displayName: 'cli',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'create-nx-plugin',
|
displayName: 'create-nx-plugin',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'create-nx-workspace',
|
displayName: 'create-nx-workspace',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'cypress',
|
displayName: 'cypress',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'cli',
|
displayName: 'cli',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'eslint-plugin-nx',
|
displayName: 'eslint-plugin-nx',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'express',
|
displayName: 'express',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'gatsby',
|
displayName: 'gatsby',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'jest',
|
displayName: 'jest',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -64,6 +64,11 @@
|
|||||||
"version": "12.1.0-beta.1",
|
"version": "12.1.0-beta.1",
|
||||||
"description": "Update jest-preset-angular to version 8.4.0",
|
"description": "Update jest-preset-angular to version 8.4.0",
|
||||||
"factory": "./src/migrations/update-12-1-0/update-jest-preset-angular"
|
"factory": "./src/migrations/update-12-1-0/update-jest-preset-angular"
|
||||||
|
},
|
||||||
|
"update-ts-jest-6-5-5": {
|
||||||
|
"version": "12.1.0-beta.1",
|
||||||
|
"description": "Replace tsConfig with tsconfig for ts-jest in jest.config.js",
|
||||||
|
"factory": "./src/migrations/update-12-1-0/update-ts-jest"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageJsonUpdates": {
|
"packageJsonUpdates": {
|
||||||
@ -137,6 +142,10 @@
|
|||||||
"jest-preset-angular": {
|
"jest-preset-angular": {
|
||||||
"version": "8.4.0",
|
"version": "8.4.0",
|
||||||
"alwaysAddToPackageJson": false
|
"alwaysAddToPackageJson": false
|
||||||
|
},
|
||||||
|
"ts-jest": {
|
||||||
|
"version": "26.5.5",
|
||||||
|
"alwaysAddToPackageJson": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ exports[`jestProject --setup-file should have setupFilesAfterEnv and globals.ts-
|
|||||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
stringifyContentPathRegex: '\\\\\\\\.(html|svg)$',
|
stringifyContentPathRegex: '\\\\\\\\.(html|svg)$',
|
||||||
astTransformers: {
|
astTransformers: {
|
||||||
before: [
|
before: [
|
||||||
@ -59,7 +59,7 @@ exports[`jestProject should create a jest.config.js 1`] = `
|
|||||||
preset: '../../jest.preset.js',
|
preset: '../../jest.preset.js',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coverageDirectory: '../../coverage/libs/lib1',
|
coverageDirectory: '../../coverage/libs/lib1',
|
||||||
|
|||||||
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],<% } %><% if (transformer === 'ts-jest') { %>
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],<% } %><% if (transformer === 'ts-jest') { %>
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',<%if (setupFile === 'angular') { %>
|
tsconfig: '<rootDir>/tsconfig.spec.json',<%if (setupFile === 'angular') { %>
|
||||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||||
astTransformers: {
|
astTransformers: {
|
||||||
before: [
|
before: [
|
||||||
|
|||||||
@ -270,7 +270,7 @@ describe('jestProject', () => {
|
|||||||
|
|
||||||
expect(jestConfig.globals).toEqual({
|
expect(jestConfig.globals).toEqual({
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
import { Tree } from '@angular-devkit/schematics';
|
||||||
|
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
|
||||||
|
import { serializeJson } from '@nrwl/workspace';
|
||||||
|
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
|
||||||
|
import * as path from 'path';
|
||||||
|
import { getJestObject } from '../update-10-0-0/require-jest-config';
|
||||||
|
import { jestConfigObject } from '../utils/config/legacy/functions';
|
||||||
|
|
||||||
|
jest.mock('../update-10-0-0/require-jest-config');
|
||||||
|
const getJestObjectMock = getJestObject as jest.Mock<typeof getJestObject>;
|
||||||
|
|
||||||
|
const jestObject = {
|
||||||
|
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('update 12.1.0', () => {
|
||||||
|
let initialTree: Tree;
|
||||||
|
let schematicRunner: SchematicTestRunner;
|
||||||
|
const jestConfig = String.raw`
|
||||||
|
module.exports = ${JSON.stringify(jestObject, null, 2)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
getJestObjectMock.mockImplementation((path: string): any => {
|
||||||
|
if (path.includes('apps/products')) {
|
||||||
|
return jestObject;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
initialTree = createEmptyWorkspace(Tree.empty());
|
||||||
|
|
||||||
|
initialTree.create('apps/products/jest.config.js', jestConfig);
|
||||||
|
initialTree.create(
|
||||||
|
'apps/products/src/test-setup.ts',
|
||||||
|
`import 'jest-preset-angular';`
|
||||||
|
);
|
||||||
|
initialTree.overwrite(
|
||||||
|
'workspace.json',
|
||||||
|
serializeJson({
|
||||||
|
version: 1,
|
||||||
|
projects: {
|
||||||
|
products: {
|
||||||
|
root: 'apps/products',
|
||||||
|
sourceRoot: 'apps/products/src',
|
||||||
|
architect: {
|
||||||
|
build: {
|
||||||
|
builder: '@angular-devkit/build-angular:browser',
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
builder: '@nrwl/jest:jest',
|
||||||
|
options: {
|
||||||
|
jestConfig: 'apps/products/jest.config.js',
|
||||||
|
passWithNoTests: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
schematicRunner = new SchematicTestRunner(
|
||||||
|
'@nrwl/jest',
|
||||||
|
path.join(__dirname, '../../../migrations.json')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the jest.config files by renaming tsConfig', async (done) => {
|
||||||
|
await schematicRunner
|
||||||
|
.runSchematicAsync('update-ts-jest-6-5-5', {}, initialTree)
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
const jestObject = jestConfigObject(
|
||||||
|
initialTree,
|
||||||
|
'apps/products/jest.config.js'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(jestObject.globals['ts-jest']['tsconfig']).toEqual(
|
||||||
|
'<rootDir>/tsconfig.spec.json'
|
||||||
|
);
|
||||||
|
expect(jestObject.globals['ts-jest']['tsConfig']).toBeUndefined();
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
59
packages/jest/src/migrations/update-12-1-0/update-ts-jest.ts
Normal file
59
packages/jest/src/migrations/update-12-1-0/update-ts-jest.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
|
||||||
|
import {
|
||||||
|
chain,
|
||||||
|
Rule,
|
||||||
|
SchematicContext,
|
||||||
|
Tree,
|
||||||
|
} from '@angular-devkit/schematics';
|
||||||
|
import { formatFiles, getWorkspace } from '@nrwl/workspace';
|
||||||
|
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { getJestObject } from '../update-10-0-0/require-jest-config';
|
||||||
|
import {
|
||||||
|
addPropertyToJestConfig,
|
||||||
|
removePropertyFromJestConfig,
|
||||||
|
} from '../utils/config/legacy/update-config';
|
||||||
|
|
||||||
|
function updateJestConfig(): Rule {
|
||||||
|
return async (host: Tree, context: SchematicContext) => {
|
||||||
|
const workspace = await getWorkspace(host);
|
||||||
|
|
||||||
|
for (const [projectName, project] of workspace.projects) {
|
||||||
|
for (const [, target] of project.targets) {
|
||||||
|
if (target.builder !== '@nrwl/jest:jest') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const jestConfigPath = target.options.jestConfig as string;
|
||||||
|
const config = getJestObject(join(appRootPath, jestConfigPath));
|
||||||
|
const tsJestConfig = config.globals['ts-jest'];
|
||||||
|
|
||||||
|
if (!tsJestConfig.tsConfig) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
removePropertyFromJestConfig(
|
||||||
|
host,
|
||||||
|
jestConfigPath,
|
||||||
|
'globals.ts-jest.tsConfig'
|
||||||
|
);
|
||||||
|
addPropertyToJestConfig(
|
||||||
|
host,
|
||||||
|
jestConfigPath,
|
||||||
|
'globals.ts-jest.tsconfig',
|
||||||
|
tsJestConfig.tsConfig
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
context.logger.error(
|
||||||
|
stripIndents`Unable to update jest.config.js for project ${projectName}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function update(): Rule {
|
||||||
|
return chain([updateJestConfig(), formatFiles()]);
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
export const nxVersion = '*';
|
export const nxVersion = '*';
|
||||||
export const jestVersion = '26.2.2';
|
export const jestVersion = '26.2.2';
|
||||||
export const jestTypesVersion = '26.0.8';
|
export const jestTypesVersion = '26.0.8';
|
||||||
export const tsJestVersion = '26.4.0';
|
export const tsJestVersion = '26.5.5';
|
||||||
|
|
||||||
export const babelCoreVersion = '7.12.13';
|
export const babelCoreVersion = '7.12.13';
|
||||||
export const babelPresetEnvVersion = '7.12.13';
|
export const babelPresetEnvVersion = '7.12.13';
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'linter',
|
displayName: 'linter',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'nest',
|
displayName: 'nest',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -509,7 +509,7 @@ describe('lib', () => {
|
|||||||
preset: '../../jest.preset.js',
|
preset: '../../jest.preset.js',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'next',
|
displayName: 'next',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'node',
|
displayName: 'node',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'nx-plugin',
|
displayName: 'nx-plugin',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,5 +5,5 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'react',
|
displayName: 'react',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' },
|
'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' },
|
||||||
},
|
},
|
||||||
displayName: 'storybook',
|
displayName: 'storybook',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'tao',
|
displayName: 'tao',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'web',
|
displayName: 'web',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
'^.+\\.[tj]sx?$': 'ts-jest',
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
globals: { 'ts-jest': { tsConfig: '<rootDir>/tsconfig.spec.json' } },
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
displayName: 'workspace',
|
displayName: 'workspace',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -117,7 +117,7 @@ describe('lib', () => {
|
|||||||
preset: '../../jest.preset.js',
|
preset: '../../jest.preset.js',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transform: {
|
transform: {
|
||||||
|
|||||||
23
yarn.lock
23
yarn.lock
@ -3696,14 +3696,6 @@
|
|||||||
jest-diff "^25.2.1"
|
jest-diff "^25.2.1"
|
||||||
pretty-format "^25.2.1"
|
pretty-format "^25.2.1"
|
||||||
|
|
||||||
"@types/jest@26.x":
|
|
||||||
version "26.0.20"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.20.tgz#cd2f2702ecf69e86b586e1f5223a60e454056307"
|
|
||||||
integrity sha512-9zi2Y+5USJRxd0FsahERhBwlcvFh6D2GLQnY2FH2BzK8J9s9omvNHIbvABwIluXa0fD8XVKMLTO0aOEuUfACAA==
|
|
||||||
dependencies:
|
|
||||||
jest-diff "^26.0.0"
|
|
||||||
pretty-format "^26.0.0"
|
|
||||||
|
|
||||||
"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6":
|
"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6":
|
||||||
version "7.0.7"
|
version "7.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
|
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
|
||||||
@ -13248,7 +13240,7 @@ jest-diff@^25.2.1:
|
|||||||
jest-get-type "^25.2.6"
|
jest-get-type "^25.2.6"
|
||||||
pretty-format "^25.5.0"
|
pretty-format "^25.5.0"
|
||||||
|
|
||||||
jest-diff@^26.0.0, jest-diff@^26.6.2:
|
jest-diff@^26.6.2:
|
||||||
version "26.6.2"
|
version "26.6.2"
|
||||||
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394"
|
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394"
|
||||||
integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==
|
integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==
|
||||||
@ -14452,7 +14444,7 @@ lodash.map@^4.5.1:
|
|||||||
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
|
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
|
||||||
integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=
|
integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=
|
||||||
|
|
||||||
lodash.memoize@4.x, lodash.memoize@^4.1.2:
|
lodash.memoize@^4.1.2:
|
||||||
version "4.1.2"
|
version "4.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
||||||
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
|
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
|
||||||
@ -21035,18 +21027,17 @@ ts-essentials@^2.0.3:
|
|||||||
resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-2.0.12.tgz#c9303f3d74f75fa7528c3d49b80e089ab09d8745"
|
resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-2.0.12.tgz#c9303f3d74f75fa7528c3d49b80e089ab09d8745"
|
||||||
integrity sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w==
|
integrity sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w==
|
||||||
|
|
||||||
ts-jest@26.4.0:
|
ts-jest@26.5.5:
|
||||||
version "26.4.0"
|
version "26.5.5"
|
||||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.0.tgz#903c7827f3d3bc33efc2f91be294b164400c32e3"
|
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.5.tgz#e40481b6ee4dd162626ba481a2be05fa57160ea5"
|
||||||
integrity sha512-ofBzoCqf6Nv/PoWb/ByV3VNKy2KJSikamOBxvR3E6eVdIw10GwAXoyvMWXXjZJK2s6S27ZE8fI+JBTnGaovl6Q==
|
integrity sha1-5ASBtu5N0WJia6SBor4F+lcWDqU=
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/jest" "26.x"
|
|
||||||
bs-logger "0.x"
|
bs-logger "0.x"
|
||||||
buffer-from "1.x"
|
buffer-from "1.x"
|
||||||
fast-json-stable-stringify "2.x"
|
fast-json-stable-stringify "2.x"
|
||||||
jest-util "^26.1.0"
|
jest-util "^26.1.0"
|
||||||
json5 "2.x"
|
json5 "2.x"
|
||||||
lodash.memoize "4.x"
|
lodash "4.x"
|
||||||
make-error "1.x"
|
make-error "1.x"
|
||||||
mkdirp "1.x"
|
mkdirp "1.x"
|
||||||
semver "7.x"
|
semver "7.x"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user