@elench/testkit 0.1.71 → 0.1.73

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.
@@ -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
- baseUrl: ".",
73
- module: "ESNext",
74
- moduleResolution: "Bundler",
75
- noEmit: true,
76
- paths: packageTypePaths(tsconfigPath),
72
+ compilerOptions: buildTypecheckCompilerOptions({
73
+ tsconfigPath,
74
+ extendsPath,
77
75
  rootDir: relativeJsonPath(tsconfigPath, productDir),
78
- target: "ES2022",
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
- baseUrl: ".",
106
- module: "ESNext",
107
- moduleResolution: "Bundler",
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
+ });
@@ -29,7 +29,12 @@ const CONFIG_NEXT_TSCONFIG_ENTRY = path.join(
29
29
  "config-api",
30
30
  "next-runtime-tsconfig.mjs"
31
31
  );
32
+ const DRIZZLE_ENTRY = path.join(PACKAGE_ROOT, "lib", "drizzle", "index.mjs");
33
+ const ENV_ENTRY = path.join(PACKAGE_ROOT, "lib", "env", "index.mjs");
34
+ const PLAYWRIGHT_ENTRY = path.join(PACKAGE_ROOT, "lib", "playwright", "index.mjs");
32
35
  const RUNTIME_ENTRY = path.join(PACKAGE_ROOT, "lib", "runtime", "index.mjs");
36
+ const VITEST_ENTRY = path.join(PACKAGE_ROOT, "lib", "vitest", "index.mjs");
37
+ const DISCOVERY_ENTRY = path.join(PACKAGE_ROOT, "lib", "discovery", "index.mjs");
33
38
  const KNOWN_FAILURES_ENTRY = path.join(PACKAGE_ROOT, "lib", "known-failures", "index.mjs");
34
39
  const MODULE_RUNNER_ENTRY = path.join(
35
40
  PACKAGE_ROOT,
@@ -252,7 +257,12 @@ function resolvePackageSubpath(specifier) {
252
257
  if (!subpath) return ROOT_ENTRY;
253
258
  if (subpath === "/config") return CONFIG_ENTRY;
254
259
  if (subpath === "/config/next-runtime-tsconfig") return CONFIG_NEXT_TSCONFIG_ENTRY;
260
+ if (subpath === "/drizzle") return DRIZZLE_ENTRY;
261
+ if (subpath === "/env") return ENV_ENTRY;
262
+ if (subpath === "/playwright") return PLAYWRIGHT_ENTRY;
255
263
  if (subpath === "/runtime") return RUNTIME_ENTRY;
264
+ if (subpath === "/vitest") return VITEST_ENTRY;
265
+ if (subpath === "/discovery") return DISCOVERY_ENTRY;
256
266
  if (subpath === "/known-failures") return KNOWN_FAILURES_ENTRY;
257
267
 
258
268
  throw new Error(`Unsupported @elench/testkit import "${specifier}" while loading template step`);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/next-analysis",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "description": "SWC-backed Next.js source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-bridge",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
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.71"
25
+ "@elench/testkit-protocol": "0.1.73"
26
26
  },
27
27
  "private": false
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-protocol",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "description": "Shared browser protocol for testkit bridge and extension consumers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/ts-analysis",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "description": "TypeScript compiler-backed source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
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.71",
84
- "@elench/ts-analysis": "0.1.71",
85
- "@elench/testkit-bridge": "0.1.71",
86
- "@elench/testkit-protocol": "0.1.71",
83
+ "@elench/next-analysis": "0.1.73",
84
+ "@elench/ts-analysis": "0.1.73",
85
+ "@elench/testkit-bridge": "0.1.73",
86
+ "@elench/testkit-protocol": "0.1.73",
87
87
  "@babel/code-frame": "^7.29.0",
88
88
  "@oclif/core": "^4.10.6",
89
89
  "esbuild": "^0.25.11",