feat(scenario): attach step output and assertion details to run log
CI / changes (pull_request) Successful in 9s
CI / version (pull_request) Skipped
CI / server (pull_request) Successful in 1m44s
CI / client (pull_request) Successful in 1m36s
CI / image (pull_request) Skipped

- "Step N passed" log entry carries the step's return value as data
- context.assert accepts an optional details argument; on failure the
  assertion:fail entry stores { details, error } as data
- assertion failures throw AssertionFailedError so "Step N failed" and
  "Snippet X failed" entries name only the assertion, without repeating
  the details; the step run description keeps the full message
- exported e2e runtime accepts and prints assert details
- log output shows elapsed time in whole seconds, matching the stored
  timestamp resolution
- run artifact and scenario file names link to the inline file content
  in a new tab
This commit is contained in:
ars9 committed 2026-10-02 11:05:29 +03:00
1 parent 2281a8729b
commit 959b3b70c9
9 files changed
+195 -17

No files matched your search

+10 -2
View File
@@ -370,7 +370,11 @@ function buildContext(page: Page, browser: BrowserContext, stepOutputs: StepOutp
log: (...args: unknown[]) => console.log(...args),
warn: (...args: unknown[]) => console.warn(...args),
error: (...args: unknown[]) => console.error(...args),
assert: async (fn: () => boolean | Promise<boolean>, description: string): Promise<void> => {
assert: async (
fn: () => boolean | Promise<boolean>,
description: string,
details?: unknown,
): Promise<void> => {
let passed: boolean;
let failureReason: string | undefined;
try {
@@ -386,7 +390,11 @@ function buildContext(page: Page, browser: BrowserContext, stepOutputs: StepOutp
const message = failureReason
? \`Assertion failed: \${description} (\${failureReason})\`
: \`Assertion failed: \${description}\`;
console.error(message);
if (details !== undefined) {
console.error(message, details);
} else {
console.error(message);
}
throw new Error(message);
},
getStepOutput: async (order: number): Promise<unknown> => {
@@ -13,7 +13,10 @@ import { Repository } from "typeorm";
import { type AppConfig, TraceMode } from "../config/app.config";
import { FileStorageService } from "../file/file-storage.service";
import type { ScriptLogger } from "../code-executor/code-executor.service";
import { CodeExecutorService } from "../code-executor/code-executor.service";
import {
CodeExecutorService,
findAssertionFailure,
} from "../code-executor/code-executor.service";
import { ExecContextBuilder } from "../code-executor/exec-context.builder";
import { traceStorage } from "../common/trace-context";
import { TraceLogger } from "../common/trace-logger";
@@ -446,7 +449,11 @@ export class ScenarioSchedulerService implements OnModuleInit {
} catch (err) {
const msg = (err as Error).message ?? String(err);
this.logger.error(`StepRun #${stepRun.id} threw: ${msg}`);
await this.failStepRun(stepRun, msg);
await this.failStepRun(
stepRun,
msg,
findAssertionFailure(err)?.summary,
);
} finally {
clearTimeout(timeoutId);
}
@@ -571,6 +578,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
"log",
`Step ${stepRun.order} passed`,
`step:${stepRun.order}`,
output,
);
// Find the next waiting step in this run (next by order)
@@ -600,9 +608,14 @@ export class ScenarioSchedulerService implements OnModuleInit {
}
}
/**
* `logSummary` replaces `description` in the "Step N failed" log entry, e.g.
* for assertion failures whose details are already logged.
*/
private async failStepRun(
stepRun: ScenarioRunStepEntity,
description: string,
logSummary?: string,
): Promise<void> {
stepRun.status = "fail";
stepRun.description = description;
@@ -612,7 +625,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRun.runId,
stepRun.id,
"error",
`Step ${stepRun.order} failed: ${description}`,
`Step ${stepRun.order} failed: ${logSummary ?? description}`,
`step:${stepRun.order}`,
);