@elench/testkit 0.1.61 → 0.1.63

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.
@@ -158,6 +158,20 @@ export function normalizeCoverageEvidence(value) {
158
158
  };
159
159
  }
160
160
 
161
+ const DIAGNOSTIC_LEVELS = new Set(["info", "warn"]);
162
+
163
+ export function normalizeCoverageGraphDiagnostic(value) {
164
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
165
+ const level = normalizeOptionalString(value.level);
166
+ const code = normalizeOptionalString(value.code);
167
+ const filePath = normalizeOptionalString(value.filePath);
168
+ const service = normalizeOptionalString(value.service);
169
+ const message = normalizeOptionalString(value.message);
170
+ if (!level || !code || !filePath || !service || !message) return null;
171
+ if (!DIAGNOSTIC_LEVELS.has(level)) return null;
172
+ return { level, code, filePath, service, message };
173
+ }
174
+
161
175
  export function normalizeCoverageGraph(value) {
162
176
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
163
177
  const schemaVersion =
@@ -169,12 +183,16 @@ export function normalizeCoverageGraph(value) {
169
183
  const evidence = Array.isArray(value.evidence)
170
184
  ? value.evidence.map(normalizeCoverageEvidence).filter(Boolean)
171
185
  : [];
186
+ const diagnostics = Array.isArray(value.diagnostics)
187
+ ? value.diagnostics.map(normalizeCoverageGraphDiagnostic).filter(Boolean)
188
+ : [];
172
189
  if (nodes.length === 0) return null;
173
190
  return {
174
191
  schemaVersion,
175
192
  nodes,
176
193
  edges,
177
194
  evidence,
195
+ diagnostics,
178
196
  };
179
197
  }
180
198
 
@@ -6,6 +6,7 @@ import {
6
6
  normalizeBrowserTarget,
7
7
  normalizeCoverageEvidence,
8
8
  normalizeCoverageGraph,
9
+ normalizeCoverageGraphDiagnostic,
9
10
  normalizeCoverageGraphEdge,
10
11
  normalizeCoverageGraphNode,
11
12
  } from "./index.mjs";
@@ -107,7 +108,79 @@ describe("testkit browser protocol", () => {
107
108
  });
108
109
  });
109
110
 
110
- it("normalizes graph payloads", () => {
111
+ it("normalizes coverage graph diagnostics", () => {
112
+ expect(
113
+ normalizeCoverageGraphDiagnostic({
114
+ level: "warn",
115
+ code: "no-service-context",
116
+ filePath: "tests/example.int.testkit.ts",
117
+ service: "web",
118
+ message: 'No coverage context available for service "web".',
119
+ })
120
+ ).toEqual({
121
+ level: "warn",
122
+ code: "no-service-context",
123
+ filePath: "tests/example.int.testkit.ts",
124
+ service: "web",
125
+ message: 'No coverage context available for service "web".',
126
+ });
127
+
128
+ expect(normalizeCoverageGraphDiagnostic({ level: "error", code: "x", filePath: "f", service: "s", message: "m" })).toBeNull();
129
+ expect(normalizeCoverageGraphDiagnostic({ level: "warn", code: "", filePath: "f", service: "s", message: "m" })).toBeNull();
130
+ expect(normalizeCoverageGraphDiagnostic(null)).toBeNull();
131
+ });
132
+
133
+ it("normalizes graph payloads with diagnostics", () => {
134
+ expect(
135
+ normalizeCoverageGraph({
136
+ schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
137
+ nodes: [
138
+ {
139
+ id: "page_view:web:/coverage",
140
+ kind: "page_view",
141
+ service: "web",
142
+ label: "Coverage",
143
+ route: "/coverage",
144
+ },
145
+ ],
146
+ edges: [],
147
+ evidence: [],
148
+ diagnostics: [
149
+ {
150
+ level: "info",
151
+ code: "zero-coverage-inferred",
152
+ filePath: "tests/example.pw.testkit.ts",
153
+ service: "web",
154
+ message: "No routes matched.",
155
+ },
156
+ ],
157
+ })
158
+ ).toEqual({
159
+ schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
160
+ nodes: [
161
+ {
162
+ id: "page_view:web:/coverage",
163
+ kind: "page_view",
164
+ service: "web",
165
+ label: "Coverage",
166
+ route: "/coverage",
167
+ },
168
+ ],
169
+ edges: [],
170
+ evidence: [],
171
+ diagnostics: [
172
+ {
173
+ level: "info",
174
+ code: "zero-coverage-inferred",
175
+ filePath: "tests/example.pw.testkit.ts",
176
+ service: "web",
177
+ message: "No routes matched.",
178
+ },
179
+ ],
180
+ });
181
+ });
182
+
183
+ it("normalizes graph payloads without diagnostics field", () => {
111
184
  expect(
112
185
  normalizeCoverageGraph({
113
186
  schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
@@ -136,6 +209,7 @@ describe("testkit browser protocol", () => {
136
209
  ],
137
210
  edges: [],
138
211
  evidence: [],
212
+ diagnostics: [],
139
213
  });
140
214
  });
141
215
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -59,8 +59,8 @@
59
59
  "vitest": "^3.2.4"
60
60
  },
61
61
  "dependencies": {
62
- "@elench/testkit-bridge": "0.1.61",
63
- "@elench/testkit-protocol": "0.1.61",
62
+ "@elench/testkit-bridge": "0.1.63",
63
+ "@elench/testkit-protocol": "0.1.63",
64
64
  "@babel/code-frame": "^7.29.0",
65
65
  "@oclif/core": "^4.10.6",
66
66
  "esbuild": "^0.25.11",