@elench/testkit 0.1.71 → 0.1.72
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/lib/app/typecheck.mjs +51 -17
- package/lib/app/typecheck.test.mjs +24 -0
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/package.json +5 -5
package/lib/app/typecheck.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
|
+
import ts from "typescript";
|
|
5
6
|
import { loadConfigContext } from "../config/index.mjs";
|
|
6
7
|
import { detectNextApp } from "../config/runtime.mjs";
|
|
7
8
|
|
|
@@ -68,15 +69,11 @@ function writeRootTypecheckConfig({ productDir, configFile, outputDir }) {
|
|
|
68
69
|
const extendsPath = findExistingTsconfig(productDir) || null;
|
|
69
70
|
const config = {
|
|
70
71
|
...(extendsPath ? { extends: relativeJsonPath(tsconfigPath, extendsPath) } : {}),
|
|
71
|
-
compilerOptions: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
moduleResolution: "Bundler",
|
|
75
|
-
noEmit: true,
|
|
76
|
-
paths: packageTypePaths(tsconfigPath),
|
|
72
|
+
compilerOptions: buildTypecheckCompilerOptions({
|
|
73
|
+
tsconfigPath,
|
|
74
|
+
extendsPath,
|
|
77
75
|
rootDir: relativeJsonPath(tsconfigPath, productDir),
|
|
78
|
-
|
|
79
|
-
},
|
|
76
|
+
}),
|
|
80
77
|
include: [
|
|
81
78
|
configFile ? relativeJsonPath(tsconfigPath, configFile) : "testkit.config.ts",
|
|
82
79
|
"**/*.int.testkit.ts",
|
|
@@ -101,18 +98,16 @@ function writeNextServiceTypecheckConfig({ productDir, cwd, outputDir, serviceNa
|
|
|
101
98
|
null;
|
|
102
99
|
const config = {
|
|
103
100
|
...(extendsPath ? { extends: relativeJsonPath(tsconfigPath, extendsPath) } : {}),
|
|
104
|
-
compilerOptions: {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
noEmit: true,
|
|
109
|
-
paths: packageTypePaths(tsconfigPath),
|
|
110
|
-
target: "ES2022",
|
|
111
|
-
},
|
|
101
|
+
compilerOptions: buildTypecheckCompilerOptions({
|
|
102
|
+
tsconfigPath,
|
|
103
|
+
extendsPath,
|
|
104
|
+
}),
|
|
112
105
|
include: [
|
|
113
106
|
serviceExists(serviceDir, "next-env.d.ts") ? relativeJsonPath(tsconfigPath, path.join(serviceDir, "next-env.d.ts")) : undefined,
|
|
114
107
|
relativeGlob(tsconfigPath, serviceDir, "src/**/*.pw.testkit.ts"),
|
|
115
|
-
relativeGlob(tsconfigPath, serviceDir, "tests/**/*.ts"),
|
|
108
|
+
relativeGlob(tsconfigPath, serviceDir, "tests/playwright-fixtures/**/*.ts"),
|
|
109
|
+
relativeGlob(tsconfigPath, serviceDir, "tests/playwright-fixtures/**/*.tsx"),
|
|
110
|
+
relativeGlob(tsconfigPath, serviceDir, "tests/playwright-fixtures/**/*.mts"),
|
|
116
111
|
relativeGlob(tsconfigPath, serviceDir, ".next/types/**/*.ts"),
|
|
117
112
|
relativeGlob(tsconfigPath, serviceDir, ".next/dev/types/**/*.ts"),
|
|
118
113
|
relativeGlob(tsconfigPath, serviceDir, ".next-testkit/**/dist/types/**/*.ts"),
|
|
@@ -205,3 +200,42 @@ function packageTypePaths(tsconfigPath) {
|
|
|
205
200
|
"@elench/testkit/vitest": [relativeJsonPath(tsconfigPath, path.join(PACKAGE_ROOT, "lib", "vitest", "index.d.ts"))],
|
|
206
201
|
};
|
|
207
202
|
}
|
|
203
|
+
|
|
204
|
+
export function buildTypecheckCompilerOptions({ tsconfigPath, extendsPath, rootDir }) {
|
|
205
|
+
const inheritedPaths = extendsPath ? resolveInheritedPathMappings({ tsconfigPath, extendsPath }) : {};
|
|
206
|
+
const paths = {
|
|
207
|
+
...inheritedPaths,
|
|
208
|
+
...packageTypePaths(tsconfigPath),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
baseUrl: ".",
|
|
213
|
+
module: "ESNext",
|
|
214
|
+
moduleResolution: "Bundler",
|
|
215
|
+
noEmit: true,
|
|
216
|
+
...(rootDir ? { rootDir } : {}),
|
|
217
|
+
target: "ES2022",
|
|
218
|
+
...(Object.keys(paths).length > 0 ? { paths } : {}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function resolveInheritedPathMappings({ tsconfigPath, extendsPath }) {
|
|
223
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(extendsPath, {}, {
|
|
224
|
+
...ts.sys,
|
|
225
|
+
onUnRecoverableConfigFileDiagnostic: () => {},
|
|
226
|
+
});
|
|
227
|
+
const compilerPaths = parsed?.options?.paths;
|
|
228
|
+
if (!compilerPaths || Object.keys(compilerPaths).length === 0) {
|
|
229
|
+
return {};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const baseDir = parsed?.options?.baseUrl || path.dirname(extendsPath);
|
|
233
|
+
const mappedEntries = Object.entries(compilerPaths).map(([alias, targets]) => {
|
|
234
|
+
const normalizedTargets = Array.isArray(targets)
|
|
235
|
+
? targets.map((target) => relativeJsonPath(tsconfigPath, path.resolve(baseDir, target)))
|
|
236
|
+
: [];
|
|
237
|
+
return [alias, normalizedTargets];
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return Object.fromEntries(mappedEntries);
|
|
241
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { buildTypecheckCompilerOptions } from "./typecheck.mjs";
|
|
4
|
+
|
|
5
|
+
describe("typecheck app helpers", () => {
|
|
6
|
+
it("preserves inherited service alias paths when generating next-service configs", () => {
|
|
7
|
+
const fixtureRoot = "/home/georgedlr/workspace/elench/bourne";
|
|
8
|
+
const extendsPath = path.join(fixtureRoot, "frontend", "tsconfig.json");
|
|
9
|
+
const generatedTsconfig = path.join(fixtureRoot, ".testkit", "_typecheck", "frontend.tsconfig.json");
|
|
10
|
+
|
|
11
|
+
const compilerOptions = buildTypecheckCompilerOptions({
|
|
12
|
+
tsconfigPath: generatedTsconfig,
|
|
13
|
+
extendsPath,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(compilerOptions.paths?.["@/*"]).toEqual(["../../frontend/src/*"]);
|
|
17
|
+
expect(compilerOptions.paths?.["@playwright-fixtures/*"]).toEqual([
|
|
18
|
+
"../../frontend/tests/playwright-fixtures/*",
|
|
19
|
+
]);
|
|
20
|
+
expect(compilerOptions.paths?.["@elench/testkit/config"]?.[0]).toMatch(
|
|
21
|
+
/(?:\.\.\/)+(?:node_modules\/@elench\/testkit|testkit)\/lib\/config-api\/index\.d\.ts$/
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"description": "Browser bridge helpers for testkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@elench/testkit-protocol": "0.1.
|
|
25
|
+
"@elench/testkit-protocol": "0.1.72"
|
|
26
26
|
},
|
|
27
27
|
"private": false
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -80,10 +80,10 @@
|
|
|
80
80
|
"vitest": "^3.2.4"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@elench/next-analysis": "0.1.
|
|
84
|
-
"@elench/ts-analysis": "0.1.
|
|
85
|
-
"@elench/testkit-bridge": "0.1.
|
|
86
|
-
"@elench/testkit-protocol": "0.1.
|
|
83
|
+
"@elench/next-analysis": "0.1.72",
|
|
84
|
+
"@elench/ts-analysis": "0.1.72",
|
|
85
|
+
"@elench/testkit-bridge": "0.1.72",
|
|
86
|
+
"@elench/testkit-protocol": "0.1.72",
|
|
87
87
|
"@babel/code-frame": "^7.29.0",
|
|
88
88
|
"@oclif/core": "^4.10.6",
|
|
89
89
|
"esbuild": "^0.25.11",
|