@nx/jest 20.0.0-beta.3 → 20.0.0-beta.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "20.0.0-beta.
|
|
3
|
+
"version": "20.0.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jest/reporters": "^29.4.1",
|
|
39
39
|
"@jest/test-result": "^29.4.1",
|
|
40
|
-
"@nx/devkit": "20.0.0-beta.
|
|
41
|
-
"@nx/js": "20.0.0-beta.
|
|
40
|
+
"@nx/devkit": "20.0.0-beta.4",
|
|
41
|
+
"@nx/js": "20.0.0-beta.4",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"chalk": "^4.1.0",
|
|
44
44
|
"identity-obj-proxy": "3.0.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"semver": "^7.5.3",
|
|
51
51
|
"tslib": "^2.3.0",
|
|
52
52
|
"yargs-parser": "21.1.1",
|
|
53
|
-
"@nrwl/jest": "20.0.0-beta.
|
|
53
|
+
"@nrwl/jest": "20.0.0-beta.4"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
1
2
|
import { JestProjectSchema } from './schema';
|
|
2
|
-
import { Tree, GeneratorCallback } from '@nx/devkit';
|
|
3
3
|
export declare function configurationGenerator(tree: Tree, schema: JestProjectSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export declare function configurationGeneratorInternal(tree: Tree, schema: JestProjectSchema): Promise<GeneratorCallback>;
|
|
5
5
|
export default configurationGenerator;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configurationGenerator = configurationGenerator;
|
|
4
4
|
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const config_file_1 = require("../../utils/config/config-file");
|
|
5
8
|
const init_1 = require("../init/init");
|
|
6
9
|
const check_for_test_target_1 = require("./lib/check-for-test-target");
|
|
7
10
|
const create_files_1 = require("./lib/create-files");
|
|
@@ -10,9 +13,6 @@ const ensure_dependencies_1 = require("./lib/ensure-dependencies");
|
|
|
10
13
|
const update_tsconfig_1 = require("./lib/update-tsconfig");
|
|
11
14
|
const update_vscode_recommended_extensions_1 = require("./lib/update-vscode-recommended-extensions");
|
|
12
15
|
const update_workspace_1 = require("./lib/update-workspace");
|
|
13
|
-
const devkit_1 = require("@nx/devkit");
|
|
14
|
-
const js_1 = require("@nx/js");
|
|
15
|
-
const config_file_1 = require("../../utils/config/config-file");
|
|
16
16
|
const schemaDefaults = {
|
|
17
17
|
setupFile: 'none',
|
|
18
18
|
babelJest: false,
|
|
@@ -84,6 +84,31 @@ async function configurationGeneratorInternal(tree, schema) {
|
|
|
84
84
|
if (!schema.skipFormat) {
|
|
85
85
|
await (0, devkit_1.formatFiles)(tree);
|
|
86
86
|
}
|
|
87
|
+
tasks.push(getUnsupportedModuleResolutionWarningTask(tree));
|
|
87
88
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
88
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* For Jest < 30, there is no way to load jest.config.ts file if the tsconfig.json/tsconfig.base.json sets moduleResolution to bundler or nodenext.
|
|
92
|
+
* Jest uses ts-node in a way that is not compatible, so until this is fixed we need to log a warning.
|
|
93
|
+
* See: https://github.com/jestjs/jest/blob/main/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L145-L153
|
|
94
|
+
*/
|
|
95
|
+
function getUnsupportedModuleResolutionWarningTask(tree) {
|
|
96
|
+
const tsConfigFileName = (0, js_1.getRootTsConfigFileName)(tree);
|
|
97
|
+
if (tsConfigFileName) {
|
|
98
|
+
const json = (0, devkit_1.readJson)(tree, tsConfigFileName);
|
|
99
|
+
if (json.compilerOptions.moduleResolution !== 'node' &&
|
|
100
|
+
json.compilerOptions.moduleResolution !== 'node10') {
|
|
101
|
+
return () => {
|
|
102
|
+
devkit_1.output.warn({
|
|
103
|
+
title: `Compiler option 'moduleResolution' in ${tsConfigFileName} must be 'node' or 'node10'`,
|
|
104
|
+
bodyLines: [
|
|
105
|
+
`Jest requires 'moduleResolution' to be set to 'node' or 'node10' to work properly. It would need to be changed in the "${tsConfigFileName}" file. It's not enough to override the compiler option in the project's tsconfig file.`,
|
|
106
|
+
`Alternatively, you can use the environment variable \`TS_NODE_COMPILER_OPTIONS='{"moduleResolution": "node10"}'\` to override Jest's usage of ts-node.`,
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return () => { };
|
|
113
|
+
}
|
|
89
114
|
exports.default = configurationGenerator;
|
|
@@ -14,7 +14,7 @@ export default { ...nxPreset };`);
|
|
|
14
14
|
else {
|
|
15
15
|
// js or cjs
|
|
16
16
|
tree.write(`jest.preset.${presetExt}`, `const nxPreset = require('@nx/jest/preset').default;
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
module.exports = { ...nxPreset };`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -91,17 +91,15 @@ module.exports = { ...nxPreset };`);
|
|
|
91
91
|
}
|
|
92
92
|
function generateGlobalConfig(tree, isJS) {
|
|
93
93
|
const contents = isJS
|
|
94
|
-
? (
|
|
95
|
-
const { getJestProjectsAsync } = require('@nx/jest');
|
|
94
|
+
? `const { getJestProjectsAsync } = require('@nx/jest');
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
:
|
|
101
|
-
import { getJestProjectsAsync } from '@nx/jest';
|
|
96
|
+
module.exports = async () => ({
|
|
97
|
+
projects: await getJestProjectsAsync()
|
|
98
|
+
});`
|
|
99
|
+
: `import { getJestProjectsAsync } from '@nx/jest';
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
export default async () => ({
|
|
102
|
+
projects: await getJestProjectsAsync()
|
|
103
|
+
});`;
|
|
106
104
|
tree.write(`jest.config.${isJS ? 'js' : 'ts'}`, contents);
|
|
107
105
|
}
|