@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.
@@ -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
- // ── 兜底:确保 report-data.json 始终存在 ──
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
- if (!fs.existsSync(reportDataPath)) {
270
- console.log(chalk_1.default.yellow(' ⚠ report-data.json missing — generating fallback report'));
271
- try {
272
- const confidencePath = path.join(resultDir, 'confidence-data.jsonl');
273
- if (fs.existsSync(resultsFile) && fs.existsSync(confidencePath)) {
274
- // 正常兜底:双文件都存在,调用 generateReportData 生成
275
- const reportData = await (0, reportData_1.generateReportData)({
276
- projectRoot: taskDir,
277
- resultsPath: resultsFile,
278
- confidencePath,
279
- });
280
- fs.writeFileSync(reportDataPath, JSON.stringify(reportData, null, 2));
281
- console.log(chalk_1.default.green(` ✓ Fallback report-data.json generated at: ${reportDataPath}`));
282
- }
283
- else {
284
- // 极端兜底:缺少 confidence-data.jsonl(Playwright crash 场景)
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
- // 同步到 latest 目录 → symlink 指向最新 round(避免重复拷贝 34MB+)
310
- const latestDir = path.join(taskDir, 'test-artifacts', 'latest');
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
- catch (err) {
328
- console.error(chalk_1.default.red(` ✗ Fallback report generation failed: ${err.message}`));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkeve/suite",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "AI-powered full-stack test agent CLI - static analysis, unit test, component test, E2E test, execute, evaluate, and report",
5
5
  "license": "MIT",
6
6
  "bin": {