@midscene/test 1.17.5-beta-20261102094111.0 → 1.17.5

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.
@@ -8,7 +8,7 @@ import { createHash, randomUUID } from "node:crypto";
8
8
  import { JSON_SCHEMA, load } from "js-yaml";
9
9
  import { mkdir, writeFile } from "node:fs/promises";
10
10
  import { setMaxListeners } from "node:events";
11
- import { TestRunReportAssembler, calculateTestRunHealth } from "@midscene/core/report";
11
+ import { ReportSession, TestRunReportAssembler, calculateTestRunHealth } from "@midscene/core/report";
12
12
  import { getDebug, runWithConsoleLogScope } from "@midscene/shared/logger";
13
13
  import "node:util";
14
14
  import { globalConfigManager } from "@midscene/shared/env";
@@ -1880,6 +1880,10 @@ const latestById = (items, id)=>[
1880
1880
  ];
1881
1881
  const notRunSuite = (prepared, reason)=>prepared.documents.flatMap((document)=>document.cases.map((item)=>asNotRun(document.documentId, item, prepared.project.name, reason)));
1882
1882
  async function runPreparedTestProject(plan) {
1883
+ const reports = new ReportSession(join(plan.runDir, 'records'));
1884
+ return reports.run(()=>runWithReportSession(plan, reports));
1885
+ }
1886
+ async function runWithReportSession(plan, reports) {
1883
1887
  const { startedAt, runId, projectRoot, configPath, resultDir, runDir, summaryPath, reportDir, definition, projects: preparedProjects } = plan;
1884
1888
  const progress = plan.onProgress;
1885
1889
  const totalDocuments = preparedProjects.reduce((total, prepared)=>total + prepared.documents.length, 0);
@@ -2089,6 +2093,10 @@ async function runPreparedTestProject(plan) {
2089
2093
  } : {},
2090
2094
  result: completedResult
2091
2095
  }));
2096
+ let extraSources = [];
2097
+ await publish('write-report', reports.directory, async ()=>{
2098
+ extraSources = await reports.finish();
2099
+ });
2092
2100
  const writeReport = ()=>publish('write-report', reportDir, async ()=>{
2093
2101
  if (!plan.reportEnabled) return;
2094
2102
  const reportPath = await new TestRunReportAssembler().assembleAsync({
@@ -2096,7 +2104,13 @@ async function runPreparedTestProject(plan) {
2096
2104
  outputFormat: plan.definition.output.reportFormat,
2097
2105
  reportFileName: `midscene-e2e-${runId}`,
2098
2106
  overwrite: false,
2099
- sources: collectTestRunReportSources(completedResult),
2107
+ sources: [
2108
+ ...collectTestRunReportSources(completedResult),
2109
+ ...extraSources.map((source)=>({
2110
+ ...source,
2111
+ scopeId: runId
2112
+ }))
2113
+ ],
2100
2114
  buildRunnerDump: (index)=>{
2101
2115
  reportIndex = index;
2102
2116
  const dump = buildTestRunReportDump(completedResult, index);
@@ -2137,6 +2151,7 @@ async function runPreparedTestProject(plan) {
2137
2151
  markdownPath
2138
2152
  };
2139
2153
  });
2154
+ if (completedResult.reportPath && !hasInfrastructureError) await publish('write-result', reports.directory, ()=>reports.prune());
2140
2155
  await writeSummary();
2141
2156
  if (hasInfrastructureError) throw new WorkflowExecutionFailure(completedResult, infrastructureErrors);
2142
2157
  return completedResult;