@nx/jest 22.4.0-canary.20260112-6cca28c → 22.4.0-canary.20260114-45f2ae3
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": "22.4.0-canary.
|
|
3
|
+
"version": "22.4.0-canary.20260114-45f2ae3",
|
|
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,14 +37,14 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jest/reporters": "^30.0.2",
|
|
39
39
|
"@jest/test-result": "^30.0.2",
|
|
40
|
-
"@nx/devkit": "22.4.0-canary.
|
|
41
|
-
"@nx/js": "22.4.0-canary.
|
|
42
|
-
"@phenomnomnominal/tsquery": "~
|
|
40
|
+
"@nx/devkit": "22.4.0-canary.20260114-45f2ae3",
|
|
41
|
+
"@nx/js": "22.4.0-canary.20260114-45f2ae3",
|
|
42
|
+
"@phenomnomnominal/tsquery": "~6.1.4",
|
|
43
43
|
"identity-obj-proxy": "3.0.0",
|
|
44
44
|
"jest-config": "^30.0.2",
|
|
45
45
|
"jest-resolve": "^30.0.2",
|
|
46
46
|
"jest-util": "^30.0.2",
|
|
47
|
-
"minimatch": "
|
|
47
|
+
"minimatch": "10.1.1",
|
|
48
48
|
"picocolors": "^1.1.0",
|
|
49
49
|
"resolve.exports": "2.0.3",
|
|
50
50
|
"semver": "^7.6.3",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"yargs-parser": "21.1.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"nx": "22.4.0-canary.
|
|
55
|
+
"nx": "22.4.0-canary.20260114-45f2ae3"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -26,7 +26,7 @@ async function default_1(tree) {
|
|
|
26
26
|
for (const testFilePath of testFilePaths) {
|
|
27
27
|
let testFileContent = tree.read(testFilePath, 'utf-8');
|
|
28
28
|
for (const [alias, matcher] of matcherAliasesMap) {
|
|
29
|
-
testFileContent = tsquery_1.
|
|
29
|
+
testFileContent = (0, tsquery_1.replace)(testFileContent, `CallExpression PropertyAccessExpression:has(CallExpression Identifier[name=expect]) Identifier[name=${alias}]`, (_node) => matcher);
|
|
30
30
|
}
|
|
31
31
|
tree.write(testFilePath, testFileContent);
|
|
32
32
|
}
|
|
@@ -29,7 +29,7 @@ async function convertJestConfigToCjs(tree) {
|
|
|
29
29
|
// is what we're trying to address.
|
|
30
30
|
if (!isJestPluginRegistered(tree))
|
|
31
31
|
return;
|
|
32
|
-
const {
|
|
32
|
+
const { ast: parseAst, query } = require('@phenomnomnominal/tsquery');
|
|
33
33
|
const jestConfigPaths = await (0, devkit_1.globAsync)(tree, ['**/jest.config.ts']);
|
|
34
34
|
const projectsWithEsmOnlyFeatures = [];
|
|
35
35
|
const projectsWithTypeModule = [];
|
|
@@ -60,15 +60,15 @@ async function convertJestConfigToCjs(tree) {
|
|
|
60
60
|
}
|
|
61
61
|
let content = tree.read(configPath, 'utf-8');
|
|
62
62
|
// Check for ESM-only features that can't be converted
|
|
63
|
-
const hasImportMeta =
|
|
63
|
+
const hasImportMeta = query(content, 'MetaProperty').length > 0 ||
|
|
64
64
|
content.includes('import.meta');
|
|
65
|
-
const hasTopLevelAwait = checkForTopLevelAwait(content,
|
|
65
|
+
const hasTopLevelAwait = checkForTopLevelAwait(content, parseAst, query);
|
|
66
66
|
if (hasImportMeta || hasTopLevelAwait) {
|
|
67
67
|
projectsWithEsmOnlyFeatures.push(configPath);
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
|
-
content = convertImportsToRequire(content,
|
|
71
|
-
content = convertExportDefaultToModuleExports(content,
|
|
70
|
+
content = convertImportsToRequire(content, parseAst, query);
|
|
71
|
+
content = convertExportDefaultToModuleExports(content, query);
|
|
72
72
|
tree.write(configPath, content);
|
|
73
73
|
modifiedFiles.push(configPath);
|
|
74
74
|
}
|
|
@@ -92,11 +92,11 @@ async function convertJestConfigToCjs(tree) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
function checkForTopLevelAwait(content,
|
|
95
|
+
function checkForTopLevelAwait(content, parseAst, query) {
|
|
96
96
|
const ts = require('typescript');
|
|
97
97
|
// Check for await expressions that are not inside a function
|
|
98
|
-
const
|
|
99
|
-
const awaitExpressions =
|
|
98
|
+
const sourceFile = parseAst(content);
|
|
99
|
+
const awaitExpressions = query(sourceFile, 'AwaitExpression');
|
|
100
100
|
for (const awaitExpr of awaitExpressions) {
|
|
101
101
|
let parent = awaitExpr.parent;
|
|
102
102
|
let isInsideFunction = false;
|
|
@@ -113,10 +113,10 @@ function checkForTopLevelAwait(content, tsquery) {
|
|
|
113
113
|
}
|
|
114
114
|
return false;
|
|
115
115
|
}
|
|
116
|
-
function convertImportsToRequire(content,
|
|
116
|
+
function convertImportsToRequire(content, parseAst, query) {
|
|
117
117
|
const ts = require('typescript');
|
|
118
|
-
const
|
|
119
|
-
const importDeclarations =
|
|
118
|
+
const sourceFile = parseAst(content);
|
|
119
|
+
const importDeclarations = query(sourceFile, 'ImportDeclaration');
|
|
120
120
|
if (importDeclarations.length === 0) {
|
|
121
121
|
return content;
|
|
122
122
|
}
|
|
@@ -166,9 +166,9 @@ function convertImportsToRequire(content, tsquery) {
|
|
|
166
166
|
}
|
|
167
167
|
return content;
|
|
168
168
|
}
|
|
169
|
-
function convertExportDefaultToModuleExports(content,
|
|
169
|
+
function convertExportDefaultToModuleExports(content, query) {
|
|
170
170
|
// Handle: export default { ... }
|
|
171
|
-
const exportAssignments =
|
|
171
|
+
const exportAssignments = query(content, 'ExportAssignment');
|
|
172
172
|
if (exportAssignments.length > 0) {
|
|
173
173
|
for (const exportAssignment of exportAssignments) {
|
|
174
174
|
const expression = exportAssignment.expression;
|
package/src/utils/ast-utils.js
CHANGED
|
@@ -13,16 +13,16 @@ exports.TEST_FILE_PATTERN = new RegExp('.*(spec|test).[jt]sx?$');
|
|
|
13
13
|
exports.TS_QUERY_JEST_CONFIG_PREFIX = ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))';
|
|
14
14
|
function addTransformerToConfig(configContents, transformer) {
|
|
15
15
|
// TODO make sure there isn't an existing matching transformer regex
|
|
16
|
-
const transformerConfig = tsquery_1.
|
|
16
|
+
const transformerConfig = (0, tsquery_1.query)(configContents, `${exports.TS_QUERY_JEST_CONFIG_PREFIX} > ObjectLiteralExpression PropertyAssignment:has(Identifier[name="transform"])`);
|
|
17
17
|
if (transformerConfig.length === 0) {
|
|
18
|
-
return tsquery_1.
|
|
18
|
+
return (0, tsquery_1.replace)(configContents, `${exports.TS_QUERY_JEST_CONFIG_PREFIX} > ObjectLiteralExpression`, (node) => {
|
|
19
19
|
return `{
|
|
20
20
|
${node.properties.map((p) => p.getText()).join(',\n')},
|
|
21
21
|
transform: { ${transformer} }
|
|
22
22
|
}`;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return tsquery_1.
|
|
25
|
+
return (0, tsquery_1.replace)(configContents, `${exports.TS_QUERY_JEST_CONFIG_PREFIX} > ObjectLiteralExpression PropertyAssignment:has(Identifier[name="transform"])`, (node) => {
|
|
26
26
|
const transformObject = node.initializer;
|
|
27
27
|
const transformProperties = transformObject.properties
|
|
28
28
|
.map((p) => p.getText())
|