@nx/jest 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +17 -0
- package/generators.json +34 -0
- package/index.d.ts +5 -0
- package/index.js +16 -0
- package/index.js.map +1 -0
- package/migrations.json +275 -0
- package/package.json +57 -0
- package/plugins/resolver.d.ts +1 -0
- package/plugins/resolver.js +56 -0
- package/plugins/resolver.js.map +1 -0
- package/preset/index.d.ts +2 -0
- package/preset/index.js +5 -0
- package/preset/index.js.map +1 -0
- package/preset/jest-preset.d.ts +2 -0
- package/preset/jest-preset.js +34 -0
- package/preset/jest-preset.js.map +1 -0
- package/src/executors/jest/compat.d.ts +2 -0
- package/src/executors/jest/compat.js +6 -0
- package/src/executors/jest/compat.js.map +1 -0
- package/src/executors/jest/jest.impl.d.ts +11 -0
- package/src/executors/jest/jest.impl.js +153 -0
- package/src/executors/jest/jest.impl.js.map +1 -0
- package/src/executors/jest/schema.d.ts +42 -0
- package/src/executors/jest/schema.json +218 -0
- package/src/executors/jest/summary.d.ts +7 -0
- package/src/executors/jest/summary.js +155 -0
- package/src/executors/jest/summary.js.map +1 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +169 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +11 -0
- package/src/generators/init/schema.json +42 -0
- package/src/generators/jest-project/files/jest.config.ts__tmpl__ +16 -0
- package/src/generators/jest-project/files/src/test-setup.ts__tmpl__ +0 -0
- package/src/generators/jest-project/files/tsconfig.spec.json__tmpl__ +21 -0
- package/src/generators/jest-project/files-angular/jest.config.ts__tmpl__ +27 -0
- package/src/generators/jest-project/files-angular/src/test-setup.ts__tmpl__ +1 -0
- package/src/generators/jest-project/files-angular/tsconfig.spec.json__tmpl__ +22 -0
- package/src/generators/jest-project/jest-project.d.ts +4 -0
- package/src/generators/jest-project/jest-project.js +55 -0
- package/src/generators/jest-project/jest-project.js.map +1 -0
- package/src/generators/jest-project/lib/check-for-test-target.d.ts +3 -0
- package/src/generators/jest-project/lib/check-for-test-target.js +13 -0
- package/src/generators/jest-project/lib/check-for-test-target.js.map +1 -0
- package/src/generators/jest-project/lib/create-files.d.ts +3 -0
- package/src/generators/jest-project/lib/create-files.js +44 -0
- package/src/generators/jest-project/lib/create-files.js.map +1 -0
- package/src/generators/jest-project/lib/update-jestconfig.d.ts +3 -0
- package/src/generators/jest-project/lib/update-jestconfig.js +22 -0
- package/src/generators/jest-project/lib/update-jestconfig.js.map +1 -0
- package/src/generators/jest-project/lib/update-tsconfig.d.ts +3 -0
- package/src/generators/jest-project/lib/update-tsconfig.js +22 -0
- package/src/generators/jest-project/lib/update-tsconfig.js.map +1 -0
- package/src/generators/jest-project/lib/update-workspace.d.ts +3 -0
- package/src/generators/jest-project/lib/update-workspace.js +37 -0
- package/src/generators/jest-project/lib/update-workspace.js.map +1 -0
- package/src/generators/jest-project/schema.d.ts +23 -0
- package/src/generators/jest-project/schema.json +80 -0
- package/src/migrations/update-12-1-2/update-jest-preset-angular.d.ts +1 -0
- package/src/migrations/update-12-1-2/update-jest-preset-angular.js +55 -0
- package/src/migrations/update-12-1-2/update-jest-preset-angular.js.map +1 -0
- package/src/migrations/update-12-1-2/update-ts-jest.d.ts +2 -0
- package/src/migrations/update-12-1-2/update-ts-jest.js +36 -0
- package/src/migrations/update-12-1-2/update-ts-jest.js.map +1 -0
- package/src/migrations/update-12-4-0/add-test-environment-for-node.d.ts +2 -0
- package/src/migrations/update-12-4-0/add-test-environment-for-node.js +38 -0
- package/src/migrations/update-12-4-0/add-test-environment-for-node.js.map +1 -0
- package/src/migrations/update-12-4-0/update-jest-preset-angular.d.ts +25 -0
- package/src/migrations/update-12-4-0/update-jest-preset-angular.js +89 -0
- package/src/migrations/update-12-4-0/update-jest-preset-angular.js.map +1 -0
- package/src/migrations/update-12-6-0/update-base-jest-config.d.ts +2 -0
- package/src/migrations/update-12-6-0/update-base-jest-config.js +43 -0
- package/src/migrations/update-12-6-0/update-base-jest-config.js.map +1 -0
- package/src/migrations/update-13-1-2/update-tsconfigs-for-tests.d.ts +2 -0
- package/src/migrations/update-13-1-2/update-tsconfigs-for-tests.js +60 -0
- package/src/migrations/update-13-1-2/update-tsconfigs-for-tests.js.map +1 -0
- package/src/migrations/update-13-4-4/add-missing-root-babel-config.d.ts +2 -0
- package/src/migrations/update-13-4-4/add-missing-root-babel-config.js +43 -0
- package/src/migrations/update-13-4-4/add-missing-root-babel-config.js.map +1 -0
- package/src/migrations/update-14-0-0/update-jest-config-ext.d.ts +3 -0
- package/src/migrations/update-14-0-0/update-jest-config-ext.js +115 -0
- package/src/migrations/update-14-0-0/update-jest-config-ext.js.map +1 -0
- package/src/migrations/update-14-1-5/update-exports-jest-config.d.ts +7 -0
- package/src/migrations/update-14-1-5/update-exports-jest-config.js +66 -0
- package/src/migrations/update-14-1-5/update-exports-jest-config.js.map +1 -0
- package/src/migrations/update-14-6-0/update-configs-jest-28.d.ts +5 -0
- package/src/migrations/update-14-6-0/update-configs-jest-28.js +82 -0
- package/src/migrations/update-14-6-0/update-configs-jest-28.js.map +1 -0
- package/src/migrations/update-14-6-0/update-tests-jest-28.d.ts +24 -0
- package/src/migrations/update-14-6-0/update-tests-jest-28.js +158 -0
- package/src/migrations/update-14-6-0/update-tests-jest-28.js.map +1 -0
- package/src/migrations/update-15-0-0/add-jest-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-jest-inputs.js +47 -0
- package/src/migrations/update-15-0-0/add-jest-inputs.js.map +1 -0
- package/src/migrations/update-15-8-0/update-configs-jest-29.d.ts +3 -0
- package/src/migrations/update-15-8-0/update-configs-jest-29.js +153 -0
- package/src/migrations/update-15-8-0/update-configs-jest-29.js.map +1 -0
- package/src/migrations/update-15-8-0/update-tests-jest-29.d.ts +5 -0
- package/src/migrations/update-15-8-0/update-tests-jest-29.js +64 -0
- package/src/migrations/update-15-8-0/update-tests-jest-29.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/ast-utils.d.ts +9 -0
- package/src/utils/ast-utils.js +33 -0
- package/src/utils/ast-utils.js.map +1 -0
- package/src/utils/config/find-root-jest-files.d.ts +3 -0
- package/src/utils/config/find-root-jest-files.js +21 -0
- package/src/utils/config/find-root-jest-files.js.map +1 -0
- package/src/utils/config/functions.d.ts +17 -0
- package/src/utils/config/functions.js +214 -0
- package/src/utils/config/functions.js.map +1 -0
- package/src/utils/config/get-jest-projects.d.ts +19 -0
- package/src/utils/config/get-jest-projects.js +64 -0
- package/src/utils/config/get-jest-projects.js.map +1 -0
- package/src/utils/config/update-config.d.ts +20 -0
- package/src/utils/config/update-config.js +84 -0
- package/src/utils/config/update-config.js.map +1 -0
- package/src/utils/versions.d.ts +9 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxJestProject",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Add Jest Configuration to a project",
|
|
6
|
+
"description": "Add Jest Configuration to a project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the project.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "projectName"
|
|
14
|
+
},
|
|
15
|
+
"x-priority": "important"
|
|
16
|
+
},
|
|
17
|
+
"skipSetupFile": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Skips the setup file required for angular.",
|
|
20
|
+
"default": false,
|
|
21
|
+
"x-deprecated": "Use `--setup-file` instead."
|
|
22
|
+
},
|
|
23
|
+
"setupFile": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": ["none", "angular", "web-components"],
|
|
26
|
+
"description": "The setup file to be generated.",
|
|
27
|
+
"default": "none",
|
|
28
|
+
"x-priority": "important"
|
|
29
|
+
},
|
|
30
|
+
"skipSerializers": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"description": "Skips the serializers required to snapshot angular templates.",
|
|
33
|
+
"default": false
|
|
34
|
+
},
|
|
35
|
+
"supportTsx": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Setup `tsx` support.",
|
|
38
|
+
"default": false,
|
|
39
|
+
"x-priority": "important"
|
|
40
|
+
},
|
|
41
|
+
"testEnvironment": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"enum": ["jsdom", "node", "none"],
|
|
44
|
+
"description": "The test environment for jest.",
|
|
45
|
+
"default": "jsdom",
|
|
46
|
+
"x-priority": "important"
|
|
47
|
+
},
|
|
48
|
+
"compiler": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"enum": ["tsc", "babel", "swc"],
|
|
51
|
+
"description": "The compiler to use for source and tests.",
|
|
52
|
+
"default": "tsc"
|
|
53
|
+
},
|
|
54
|
+
"babelJest": {
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"alias": "babel-jest",
|
|
57
|
+
"description": "Use `babel-jest` instead of `ts-jest`.",
|
|
58
|
+
"x-deprecated": "Use `--compiler=babel` instead.",
|
|
59
|
+
"default": false
|
|
60
|
+
},
|
|
61
|
+
"skipFormat": {
|
|
62
|
+
"description": "Skip formatting files",
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"default": false,
|
|
65
|
+
"x-priority": "internal"
|
|
66
|
+
},
|
|
67
|
+
"skipPackageJson": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"default": false,
|
|
70
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
71
|
+
"x-priority": "internal"
|
|
72
|
+
},
|
|
73
|
+
"js": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"default": false,
|
|
76
|
+
"description": "Use JavaScript instead of TypeScript for config files"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": []
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function update(tree: any): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const update_config_1 = require("../../utils/config/update-config");
|
|
8
|
+
function updateJestConfig(tree) {
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, projectName) => {
|
|
10
|
+
const config = require((0, path_1.join)(tree.root, options.jestConfig));
|
|
11
|
+
// migrate serializers
|
|
12
|
+
if (config.snapshotSerializers &&
|
|
13
|
+
Array.isArray(config.snapshotSerializers)) {
|
|
14
|
+
const snapshotSerializers = config.snapshotSerializers.map((snapshotSerializer) => {
|
|
15
|
+
switch (snapshotSerializer) {
|
|
16
|
+
case 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js':
|
|
17
|
+
return 'jest-preset-angular/build/serializers/no-ng-attributes';
|
|
18
|
+
case 'jest-preset-angular/build/AngularSnapshotSerializer.js':
|
|
19
|
+
return 'jest-preset-angular/build/serializers/ng-snapshot';
|
|
20
|
+
case 'jest-preset-angular/build/HTMLCommentSerializer.js':
|
|
21
|
+
return 'jest-preset-angular/build/serializers/html-comment';
|
|
22
|
+
default:
|
|
23
|
+
return snapshotSerializer;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
(0, update_config_1.removePropertyFromJestConfig)(tree, options.jestConfig, 'snapshotSerializers');
|
|
28
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, options.jestConfig, 'snapshotSerializers', snapshotSerializers);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update snapshotSerializers for project ${projectName}.
|
|
32
|
+
More information you can check online documentation https://github.com/thymikee/jest-preset-angular/blob/master/CHANGELOG.md#840-2021-03-04`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const { sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
37
|
+
const setupTestPath = (0, path_1.join)(sourceRoot, 'test-setup.ts');
|
|
38
|
+
if (tree.exists(setupTestPath)) {
|
|
39
|
+
const contents = tree.read(setupTestPath, 'utf-8');
|
|
40
|
+
tree.write(setupTestPath, contents.replace(`import 'jest-preset-angular';`, `import 'jest-preset-angular/setup-jest';`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (_b) {
|
|
44
|
+
devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update test-setup.ts for project ${projectName}.`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function update(tree) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
updateJestConfig(tree);
|
|
51
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.default = update;
|
|
55
|
+
//# sourceMappingURL=update-jest-preset-angular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-jest-preset-angular.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-12-1-2/update-jest-preset-angular.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,6FAA0F;AAC1F,+BAA4B;AAC5B,oEAG0C;AAG1C,SAAS,gBAAgB,CAAC,IAAU;I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aAAa,EAAE,OAAO,CAAC,CAAC;gBACnD,IAAI,CAAC,KAAK,CACR,aAAa,EACb,QAAQ,CAAC,OAAO,CACd,+BAA+B,EAC/B,0CAA0C,CAC3C,CACF,CAAC;aACH;SACF;QAAC,WAAM;YACN,eAAM,CAAC,KAAK,CACV,IAAA,qBAAY,EAAA,8CAA8C,WAAW,GAAG,CACzE,CAAC;SACH;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAA8B,MAAM,CAAC,IAAI;;QACvC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAHD,yBAGC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const update_config_1 = require("../../utils/config/update-config");
|
|
8
|
+
function updateJestConfig(tree) {
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, project) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!options.jestConfig) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const jestConfigPath = options.jestConfig;
|
|
15
|
+
const config = require((0, path_1.join)(tree.root, jestConfigPath));
|
|
16
|
+
const tsJestConfig = (_a = config.globals) === null || _a === void 0 ? void 0 : _a['ts-jest'];
|
|
17
|
+
if (!(tsJestConfig && tsJestConfig.tsConfig)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
(0, update_config_1.removePropertyFromJestConfig)(tree, jestConfigPath, 'globals.ts-jest.tsConfig');
|
|
22
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, jestConfigPath, 'globals.ts-jest.tsconfig', tsJestConfig.tsConfig);
|
|
23
|
+
}
|
|
24
|
+
catch (_b) {
|
|
25
|
+
devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update jest.config.js for project ${project}.`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function update(tree) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
updateJestConfig(tree);
|
|
32
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.default = update;
|
|
36
|
+
//# sourceMappingURL=update-ts-jest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-ts-jest.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-12-1-2/update-ts-jest.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AACrE,6FAA0F;AAC1F,+BAA4B;AAE5B,oEAG0C;AAE1C,SAAS,gBAAgB,CAAC,IAAU;IAClC,IAAA,+CAAsB,EACpB,IAAI,EACJ,iBAAiB,EACjB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;;QACnB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,OAAO;SACR;QAED,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;QAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAA,WAAI,EAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;QACxD,MAAM,YAAY,GAAG,MAAA,MAAM,CAAC,OAAO,0CAAG,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,CAAC,YAAY,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;YAC5C,OAAO;SACR;QAED,IAAI;YACF,IAAA,4CAA4B,EAC1B,IAAI,EACJ,cAAc,EACd,0BAA0B,CAC3B,CAAC;YACF,IAAA,uCAAuB,EACrB,IAAI,EACJ,cAAc,EACd,0BAA0B,EAC1B,YAAY,CAAC,QAAQ,CACtB,CAAC;SACH;QAAC,WAAM;YACN,eAAM,CAAC,KAAK,CACV,IAAA,qBAAY,EAAA,+CAA+C,OAAO,GAAG,CACtE,CAAC;SACH;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAA8B,MAAM,CAAC,IAAU;;QAC7C,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAHD,yBAGC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const update_config_1 = require("../../utils/config/update-config");
|
|
8
|
+
function updateJestConfig(tree) {
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, project) => {
|
|
10
|
+
if (!options.jestConfig) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const jestConfigPath = options.jestConfig;
|
|
14
|
+
const jestConfig = require((0, path_1.join)(tree.root, jestConfigPath));
|
|
15
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
16
|
+
const testEnvironment = jestConfig.testEnvironment;
|
|
17
|
+
if (testEnvironment || !checkIfNodeProject(projectConfig)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, jestConfigPath, 'testEnvironment', 'node');
|
|
22
|
+
}
|
|
23
|
+
catch (_a) {
|
|
24
|
+
devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update jest.config.js for project ${project}.`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function update(tree) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
updateJestConfig(tree);
|
|
31
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.default = update;
|
|
35
|
+
function checkIfNodeProject(config) {
|
|
36
|
+
return Object.entries(config.targets).some(([targetName, targetConfig]) => { var _a, _b; return (_b = (_a = targetConfig.executor) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'node'); });
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=add-test-environment-for-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-test-environment-for-node.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-12-4-0/add-test-environment-for-node.ts"],"names":[],"mappings":";;;AAAA,uCAOoB;AACpB,6FAA0F;AAC1F,+BAA4B;AAE5B,oEAA2E;AAE3E,SAAS,gBAAgB,CAAC,IAAU;IAClC,IAAA,+CAAsB,EACpB,IAAI,EACJ,iBAAiB,EACjB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACnB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,OAAO;SACR;QAED,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;QAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAA,WAAI,EAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC;QAEnD,IAAI,eAAe,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE;YACzD,OAAO;SACR;QAED,IAAI;YACF,IAAA,uCAAuB,EACrB,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,MAAM,CACP,CAAC;SACH;QAAC,WAAM;YACN,eAAM,CAAC,KAAK,CACV,IAAA,qBAAY,EAAA,+CAA+C,OAAO,GAAG,CACtE,CAAC;SACH;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAA8B,MAAM,CAAC,IAAU;;QAC7C,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAHD,yBAGC;AAED,SAAS,kBAAkB,CAAC,MAA4B;IACtD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,EAAE,eACxE,OAAA,MAAA,MAAA,YAAY,CAAC,QAAQ,0CAAE,QAAQ,mDAAG,MAAM,CAAC,CAAA,EAAA,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export default function update(tree: Tree): Promise<void>;
|
|
3
|
+
export declare function updateASTTransformers(tree: Tree, jestConfigPath: string, jestConfig: PartialJestConfig): void;
|
|
4
|
+
export declare function updateTransform(tree: Tree, jestConfigPath: string, jestConfig: PartialJestConfig): void;
|
|
5
|
+
interface PartialJestConfig {
|
|
6
|
+
globals: {
|
|
7
|
+
'ts-jest': {
|
|
8
|
+
astTransformers: ASTTransformers;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
transform?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface ASTTransformer {
|
|
14
|
+
path: string;
|
|
15
|
+
options: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface ASTTransformers {
|
|
18
|
+
before: (ASTTransformer | string)[];
|
|
19
|
+
after: (ASTTransformer | string)[];
|
|
20
|
+
afterDeclarations: (ASTTransformer | string)[];
|
|
21
|
+
}
|
|
22
|
+
export declare function getNewAstTransformers(astTransformers: ASTTransformers): ASTTransformers | null;
|
|
23
|
+
export declare function transformerIsFromJestPresetAngular(transformer: ASTTransformer | string): boolean;
|
|
24
|
+
export declare function usesJestPresetAngular(jestConfig: PartialJestConfig): boolean;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usesJestPresetAngular = exports.transformerIsFromJestPresetAngular = exports.getNewAstTransformers = exports.updateTransform = exports.updateASTTransformers = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const update_config_1 = require("../../utils/config/update-config");
|
|
9
|
+
function updateJestConfig(tree) {
|
|
10
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, project) => {
|
|
11
|
+
if (!options.jestConfig) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const jestConfigPath = options.jestConfig;
|
|
15
|
+
const jestConfig = require((0, path_1.join)(tree.root, jestConfigPath));
|
|
16
|
+
if (!usesJestPresetAngular(jestConfig)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
updateASTTransformers(tree, jestConfigPath, jestConfig);
|
|
21
|
+
updateTransform(tree, jestConfigPath, jestConfig);
|
|
22
|
+
}
|
|
23
|
+
catch (_a) {
|
|
24
|
+
devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update jest.config.js for project ${project}.`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function update(tree) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
updateJestConfig(tree);
|
|
31
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.default = update;
|
|
35
|
+
function updateASTTransformers(tree, jestConfigPath, jestConfig) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const newTransformers = getNewAstTransformers((_b = (_a = jestConfig.globals) === null || _a === void 0 ? void 0 : _a['ts-jest']) === null || _b === void 0 ? void 0 : _b.astTransformers);
|
|
38
|
+
if (newTransformers === null) {
|
|
39
|
+
(0, update_config_1.removePropertyFromJestConfig)(tree, jestConfigPath, 'globals.ts-jest.astTransformers');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, jestConfigPath, 'globals.ts-jest.astTransformers', newTransformers);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.updateASTTransformers = updateASTTransformers;
|
|
46
|
+
function updateTransform(tree, jestConfigPath, jestConfig) {
|
|
47
|
+
(0, update_config_1.removePropertyFromJestConfig)(tree, jestConfigPath, 'transform');
|
|
48
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, jestConfigPath, 'transform', {
|
|
49
|
+
'^.+\\.(ts|js|html)$': 'jest-preset-angular',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.updateTransform = updateTransform;
|
|
53
|
+
function getNewAstTransformers(astTransformers) {
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
55
|
+
let result = {
|
|
56
|
+
before: (_b = (_a = astTransformers === null || astTransformers === void 0 ? void 0 : astTransformers.before) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, (x) => !transformerIsFromJestPresetAngular(x)),
|
|
57
|
+
after: (_d = (_c = astTransformers === null || astTransformers === void 0 ? void 0 : astTransformers.after) === null || _c === void 0 ? void 0 : _c.filter) === null || _d === void 0 ? void 0 : _d.call(_c, (x) => !transformerIsFromJestPresetAngular(x)),
|
|
58
|
+
afterDeclarations: (_f = (_e = astTransformers === null || astTransformers === void 0 ? void 0 : astTransformers.afterDeclarations) === null || _e === void 0 ? void 0 : _e.filter) === null || _f === void 0 ? void 0 : _f.call(_e, (x) => !transformerIsFromJestPresetAngular(x)),
|
|
59
|
+
};
|
|
60
|
+
result = {
|
|
61
|
+
before: ((_g = result.before) === null || _g === void 0 ? void 0 : _g.length) > 0 ? result.before : undefined,
|
|
62
|
+
after: ((_h = result.after) === null || _h === void 0 ? void 0 : _h.length) > 0 ? result.after : undefined,
|
|
63
|
+
afterDeclarations: ((_j = result.afterDeclarations) === null || _j === void 0 ? void 0 : _j.length) > 0
|
|
64
|
+
? result.afterDeclarations
|
|
65
|
+
: undefined,
|
|
66
|
+
};
|
|
67
|
+
if (!result.before && !result.after && !result.afterDeclarations) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.getNewAstTransformers = getNewAstTransformers;
|
|
75
|
+
function transformerIsFromJestPresetAngular(transformer) {
|
|
76
|
+
return typeof transformer === 'string'
|
|
77
|
+
? transformer.includes('jest-preset-angular')
|
|
78
|
+
: transformer.path.includes('jest-preset-angular');
|
|
79
|
+
}
|
|
80
|
+
exports.transformerIsFromJestPresetAngular = transformerIsFromJestPresetAngular;
|
|
81
|
+
function usesJestPresetAngular(jestConfig) {
|
|
82
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
83
|
+
const transformers = Array.isArray((_b = (_a = jestConfig.globals) === null || _a === void 0 ? void 0 : _a['ts-jest']) === null || _b === void 0 ? void 0 : _b.astTransformers)
|
|
84
|
+
? ((_d = (_c = jestConfig.globals) === null || _c === void 0 ? void 0 : _c['ts-jest']) === null || _d === void 0 ? void 0 : _d.astTransformers) || []
|
|
85
|
+
: ((_g = (_f = (_e = jestConfig.globals) === null || _e === void 0 ? void 0 : _e['ts-jest']) === null || _f === void 0 ? void 0 : _f.astTransformers) === null || _g === void 0 ? void 0 : _g.before) || [];
|
|
86
|
+
return transformers.some((x) => transformerIsFromJestPresetAngular(x));
|
|
87
|
+
}
|
|
88
|
+
exports.usesJestPresetAngular = usesJestPresetAngular;
|
|
89
|
+
//# sourceMappingURL=update-jest-preset-angular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-jest-preset-angular.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-12-4-0/update-jest-preset-angular.ts"],"names":[],"mappings":";;;;AAAA,uCAAqE;AACrE,6FAA0F;AAC1F,+BAA4B;AAE5B,oEAG0C;AAE1C,SAAS,gBAAgB,CAAC,IAAU;IAClC,IAAA,+CAAsB,EACpB,IAAI,EACJ,iBAAiB,EACjB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACnB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,OAAO;SACR;QAED,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;QAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAA,WAAI,EAC7B,IAAI,CAAC,IAAI,EACT,cAAc,CACf,CAAsB,CAAC;QAExB,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;YACtC,OAAO;SACR;QAED,IAAI;YACF,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;YACxD,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;SACnD;QAAC,WAAM;YACN,eAAM,CAAC,KAAK,CACV,IAAA,qBAAY,EAAA,+CAA+C,OAAO,GAAG,CACtE,CAAC;SACH;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAA8B,MAAM,CAAC,IAAU;;QAC7C,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAHD,yBAGC;AAED,SAAgB,qBAAqB,CACnC,IAAU,EACV,cAAsB,EACtB,UAA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AE,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AARD,sDAQC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const functions_1 = require("../../utils/config/functions");
|
|
6
|
+
const get_jest_projects_1 = require("../../utils/config/get-jest-projects");
|
|
7
|
+
const update_config_1 = require("../../utils/config/update-config");
|
|
8
|
+
function determineUncoveredJestProjects(existingProjects) {
|
|
9
|
+
const coveredJestProjects = (0, get_jest_projects_1.getJestProjects)().reduce((acc, key) => {
|
|
10
|
+
acc[key] = true;
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
13
|
+
return existingProjects.filter((project) => !coveredJestProjects[project]);
|
|
14
|
+
}
|
|
15
|
+
function determineProjectsValue(uncoveredJestProjects) {
|
|
16
|
+
if (!uncoveredJestProjects.length) {
|
|
17
|
+
return `getJestProjects()`;
|
|
18
|
+
}
|
|
19
|
+
return `[...getJestProjects(), ${uncoveredJestProjects
|
|
20
|
+
.map((projectName) => `'${projectName}', `)
|
|
21
|
+
.join('')}]`;
|
|
22
|
+
}
|
|
23
|
+
function updateBaseJestConfig(tree, baseJestConfigPath = 'jest.config.js') {
|
|
24
|
+
var _a;
|
|
25
|
+
if (tree.read('/jest.config.js', 'utf-8').includes('getJestProjects()')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const currentConfig = (0, functions_1.jestConfigObject)(tree, baseJestConfigPath);
|
|
29
|
+
(_a = currentConfig.projects) !== null && _a !== void 0 ? _a : (currentConfig.projects = []);
|
|
30
|
+
const uncoveredJestProjects = determineUncoveredJestProjects(currentConfig.projects);
|
|
31
|
+
(0, update_config_1.removePropertyFromJestConfig)(tree, baseJestConfigPath, 'projects');
|
|
32
|
+
(0, update_config_1.addPropertyToJestConfig)(tree, baseJestConfigPath, 'projects', determineProjectsValue(uncoveredJestProjects), { valueAsString: true });
|
|
33
|
+
(0, update_config_1.addImportStatementToJestConfig)(tree, baseJestConfigPath, `const { getJestProjects } = require('@nx/jest');`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
function update(tree) {
|
|
37
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
updateBaseJestConfig(tree);
|
|
39
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.default = update;
|
|
43
|
+
//# sourceMappingURL=update-base-jest-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-base-jest-config.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-12-6-0/update-base-jest-config.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,4DAAgE;AAChE,4EAAuE;AACvE,oEAI0C;AAE1C,SAAS,8BAA8B,CAAC,gBAA0B;IAChE,MAAM,mBAAmB,GAAI,IAAA,mCAAe,GAAe,CAAC,MAAM,CAChE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAChB,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IACF,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,sBAAsB,CAAC,qBAA+B;IAC7D,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE;QACjC,OAAO,mBAAmB,CAAC;KAC5B;IACD,OAAO,0BAA0B,qBAAqB;SACnD,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,WAAW,KAAK,CAAC;SAC1C,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;AACjB,CAAC;AAED,SAAS,oBAAoB,CAC3B,IAAU,EACV,kBAAkB,GAAG,gBAAgB;;IAErC,IAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;QACvE,OAAO;KACR;IACD,MAAM,aAAa,GAAG,IAAA,4BAAgB,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACjE,MAAA,aAAa,CAAC,QAAQ,oCAAtB,aAAa,CAAC,QAAQ,GAAK,EAAE,EAAC;IAE9B,MAAM,qBAAqB,GAAG,8BAA8B,CAC1D,aAAa,CAAC,QAAoB,CACnC,CAAC;IACF,IAAA,4CAA4B,EAAC,IAAI,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;IACnE,IAAA,uCAAuB,EACrB,IAAI,EACJ,kBAAkB,EAClB,UAAU,EACV,sBAAsB,CAAC,qBAAqB,CAAC,EAC7C,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAC;IACF,IAAA,8CAA8B,EAC5B,IAAI,EACJ,kBAAkB,EAClB,kDAAkD,CACnD,CAAC;IACF,OAAO;AACT,CAAC;AAED,SAA8B,MAAM,CAAC,IAAU;;QAC7C,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAHD,yBAGC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function updateTsConfigsForTests(tree) {
|
|
8
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (jestOptions, projectName) => {
|
|
9
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
10
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (path) => {
|
|
11
|
+
const fileName = (0, path_1.basename)(path);
|
|
12
|
+
if (fileName.startsWith('tsconfig') && fileName.endsWith('.json')) {
|
|
13
|
+
updateTsConfig(tree, path);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
function updateTsConfig(tree, tsconfigSpecPath) {
|
|
18
|
+
try {
|
|
19
|
+
(0, devkit_1.updateJson)(tree, tsconfigSpecPath, (value) => {
|
|
20
|
+
if (value.include) {
|
|
21
|
+
value.include = makeAllPatternsFromSpecPatterns(value.include);
|
|
22
|
+
}
|
|
23
|
+
if (value.exclude) {
|
|
24
|
+
value.exclude = makeAllPatternsFromSpecPatterns(value.exclude);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// issue trying to parse the tsconfig file bc it's invalid JSON from template markup/comments
|
|
31
|
+
// ignore and move on
|
|
32
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to update ${tsconfigSpecPath}. `);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* take an array of patterns and create patterns from those containing .spec. with .test.
|
|
38
|
+
* by default the pattern ** /*.spec.ts will be used if no value is passed in.
|
|
39
|
+
*/
|
|
40
|
+
function makeAllPatternsFromSpecPatterns(specGlobs = ['**/*.spec.ts']) {
|
|
41
|
+
return makeUniquePatterns(specGlobs.reduce((patterns, current) => {
|
|
42
|
+
patterns.push(current);
|
|
43
|
+
// .spec. and _spec. can used as testing file name patterns
|
|
44
|
+
if (current.includes('spec.')) {
|
|
45
|
+
patterns.push(current.replace('spec.', 'test.'));
|
|
46
|
+
}
|
|
47
|
+
return patterns;
|
|
48
|
+
}, []));
|
|
49
|
+
}
|
|
50
|
+
function makeUniquePatterns(items = []) {
|
|
51
|
+
return [...new Set(items)];
|
|
52
|
+
}
|
|
53
|
+
function update(tree) {
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
updateTsConfigsForTests(tree);
|
|
56
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.default = update;
|
|
60
|
+
//# sourceMappingURL=update-tsconfigs-for-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-tsconfigs-for-tests.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-13-1-2/update-tsconfigs-for-tests.ts"],"names":[],"mappings":";;;AAAA,uCAQoB;AACpB,6FAA0F;AAC1F,+BAAgC;AAGhC,SAAS,uBAAuB,CAAC,IAAU;IACzC,IAAA,+CAAsB,EACpB,IAAI,EACJ,iBAAiB,EACjB,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE;QAC3B,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAElE,IAAA,6BAAoB,EAAC,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;YAChC,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACjE,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;IAEF,SAAS,cAAc,CAAC,IAAU,EAAE,gBAAwB;QAC1D,IAAI;YACF,IAAA,mBAAU,EAAW,IAAI,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrD,IAAI,KAAK,CAAC,OAAO,EAAE;oBACjB,KAAK,CAAC,OAAO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slib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const functions_1 = require("../../utils/config/functions");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
function checkIfProjectNeedsUpdate(tree) {
|
|
9
|
+
if (tree.exists('babel.config.json')) {
|
|
10
|
+
// the project is already running on babel and good to go
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
let shouldUpdate = false;
|
|
14
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (jestOptions, projectName) => {
|
|
15
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
16
|
+
const jestConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'jest.config.js');
|
|
17
|
+
if (!tree.exists(jestConfigPath)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const config = (0, functions_1.jestConfigObject)(tree, jestConfigPath);
|
|
21
|
+
if (config.transform) {
|
|
22
|
+
for (const transformer of Object.values(config.transform)) {
|
|
23
|
+
if ((typeof transformer === 'string' && transformer === 'babel-jest') ||
|
|
24
|
+
(Array.isArray(transformer) && transformer[0] === 'babel-jest')) {
|
|
25
|
+
shouldUpdate = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return shouldUpdate;
|
|
31
|
+
}
|
|
32
|
+
function update(tree) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const shouldUpdateConfigs = checkIfProjectNeedsUpdate(tree);
|
|
35
|
+
if (shouldUpdateConfigs) {
|
|
36
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nrwl/web': versions_1.nxVersion });
|
|
37
|
+
tree.write('babel.config.json', '{"babelrcRoots": ["*"]}');
|
|
38
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.default = update;
|
|
43
|
+
//# sourceMappingURL=add-missing-root-babel-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-missing-root-babel-config.js","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-13-4-4/add-missing-root-babel-config.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,6FAA0F;AAE1F,4DAAgE;AAChE,mDAAiD;AAEjD,SAAS,yBAAyB,CAAC,IAAU;IAC3C,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QACpC,yDAAyD;QACzD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAA,+CAAsB,EACpB,IAAI,EACJ,iBAAiB,EACjB,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE;QAC3B,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAClE,MAAM,cAAc,GAAG,IAAA,0BAAiB,EACtC,aAAa,CAAC,IAAI,EAClB,gBAAgB,CACjB,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,OAAO;SACR;QAED,MAAM,MAAM,GAAG,IAAA,4BAAgB,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAEtD,IAAI,MAAM,CAAC,SAAS,EAAE;YACpB,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;gBACzD,IACE,CAAC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,YAAY,CAAC;oBACjE,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,EAC/D;oBACA,YAAY,GAAG,IAAI,CAAC;iBACrB;aACF;SACF;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