@kkeve/suite 0.0.10 → 0.0.11
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/dist/commands/run.js +39 -36
- package/package.json +1 -1
package/dist/commands/run.js
CHANGED
|
@@ -264,24 +264,28 @@ async function run(options) {
|
|
|
264
264
|
console.log(chalk_1.default.gray(` Passed: ${passed}, Failed: ${failed}, Skipped: ${skipped}`));
|
|
265
265
|
(0, config_1.completeRound)(taskDir, round, { passed, failed, skipped });
|
|
266
266
|
stripBase64FromTestResults(resultsFile, resultDir);
|
|
267
|
-
// ──
|
|
267
|
+
// ── 生成 report-data.json:在 Playwright 进程结束后统一生成,避免 keve-reporter 的 onEnd 与 JSON reporter 的 race condition ──
|
|
268
|
+
// keve-reporter.ts 的 onEnd 在 Playwright 进程内部执行,此时 JSON reporter 可能尚未完全刷新 test-results.json,
|
|
269
|
+
// 导致 generateReportData 读取到旧数据(specs 为空)→ 所有 case 被标记为 missing。
|
|
270
|
+
// 因此在 run() 外部(Playwright 进程结束后)统一重新生成,确保 test-results.json 已完全落盘。
|
|
268
271
|
const reportDataPath = path.join(resultDir, 'report-data.json');
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
272
|
+
try {
|
|
273
|
+
const confidencePath = path.join(resultDir, 'confidence-data.jsonl');
|
|
274
|
+
const casesPath = path.join(taskDir, 'cases', 'test-cases.yaml');
|
|
275
|
+
const reportData = await (0, reportData_1.generateReportData)({
|
|
276
|
+
projectRoot: taskDir,
|
|
277
|
+
resultsPath: resultsFile,
|
|
278
|
+
confidencePath: fs.existsSync(confidencePath) ? confidencePath : undefined,
|
|
279
|
+
casesPath: fs.existsSync(casesPath) ? casesPath : undefined,
|
|
280
|
+
});
|
|
281
|
+
fs.writeFileSync(reportDataPath, JSON.stringify(reportData, null, 2));
|
|
282
|
+
console.log(chalk_1.default.green(` ✓ report-data.json generated at: ${reportDataPath}`));
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
console.error(chalk_1.default.red(` ✗ report-data.json generation failed: ${err.message}`));
|
|
286
|
+
// 主生成失败时,若 report-data.json 仍不存在,尝试生成极简 fallback
|
|
287
|
+
if (!fs.existsSync(reportDataPath)) {
|
|
288
|
+
try {
|
|
285
289
|
const fallbackReport = {
|
|
286
290
|
round,
|
|
287
291
|
taskDir,
|
|
@@ -289,7 +293,6 @@ async function run(options) {
|
|
|
289
293
|
cases: [],
|
|
290
294
|
warning: 'report-data.json generated by fallback — some test data may be incomplete',
|
|
291
295
|
};
|
|
292
|
-
// 尝试从 test-results.json 提取基础统计
|
|
293
296
|
if (fs.existsSync(resultsFile)) {
|
|
294
297
|
try {
|
|
295
298
|
const results = JSON.parse(fs.readFileSync(resultsFile, 'utf-8'));
|
|
@@ -306,27 +309,27 @@ async function run(options) {
|
|
|
306
309
|
fs.writeFileSync(reportDataPath, JSON.stringify(fallbackReport, null, 2));
|
|
307
310
|
console.log(chalk_1.default.yellow(` ⚠ Minimal fallback report-data.json generated (missing confidence data)`));
|
|
308
311
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (latestDir !== resultDir) {
|
|
312
|
-
try {
|
|
313
|
-
if (fs.existsSync(latestDir)) {
|
|
314
|
-
const stat = fs.lstatSync(latestDir);
|
|
315
|
-
if (stat.isSymbolicLink()) {
|
|
316
|
-
fs.unlinkSync(latestDir);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
fs.rmSync(latestDir, { recursive: true, force: true });
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
fs.symlinkSync(path.basename(resultDir), latestDir, 'junction');
|
|
323
|
-
}
|
|
324
|
-
catch { /* ignore latest symlink error */ }
|
|
312
|
+
catch (fallbackErr) {
|
|
313
|
+
console.error(chalk_1.default.red(` ✗ Fallback report generation failed: ${fallbackErr.message}`));
|
|
325
314
|
}
|
|
326
315
|
}
|
|
327
|
-
|
|
328
|
-
|
|
316
|
+
}
|
|
317
|
+
// 同步到 latest 目录 → symlink 指向最新 round(避免重复拷贝 34MB+)
|
|
318
|
+
const latestDir = path.join(taskDir, 'test-artifacts', 'latest');
|
|
319
|
+
if (latestDir !== resultDir) {
|
|
320
|
+
try {
|
|
321
|
+
if (fs.existsSync(latestDir)) {
|
|
322
|
+
const stat = fs.lstatSync(latestDir);
|
|
323
|
+
if (stat.isSymbolicLink()) {
|
|
324
|
+
fs.unlinkSync(latestDir);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
fs.rmSync(latestDir, { recursive: true, force: true });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
fs.symlinkSync(path.basename(resultDir), latestDir, 'junction');
|
|
329
331
|
}
|
|
332
|
+
catch { /* ignore latest symlink error */ }
|
|
330
333
|
}
|
|
331
334
|
return { exitCode, resultsFile, resultDir, taskDir, round, passed, failed, skipped };
|
|
332
335
|
}
|
package/package.json
CHANGED