(deps: ConsoleDeps)
| 25 | } |
| 26 | |
| 27 | export function createConsoleReporter(deps: ConsoleDeps): Reporter { |
| 28 | return { |
| 29 | onFlowStart({ name, path }) { |
| 30 | deps.stdout.write( |
| 31 | `${styleText("magenta", "•")} ${styleText( |
| 32 | ["bold", "magenta"], |
| 33 | name, |
| 34 | )} ${styleText("dim", path)}\n`, |
| 35 | ); |
| 36 | }, |
| 37 | |
| 38 | onTestResult({ label, status, durationMs }) { |
| 39 | // err field intentionally unused in v0.1; errors surface at flow level via onFlowFail |
| 40 | const icon = |
| 41 | status === "pass" ? styleText("green", "✓") : styleText("red", "✗"); |
| 42 | deps.stdout.write( |
| 43 | ` - ${label} ${icon} ${styleText("dim", fmtDuration(durationMs))}\n`, |
| 44 | ); |
| 45 | }, |
| 46 | |
| 47 | onScreenshot({ path }) { |
| 48 | deps.stdout.write( |
| 49 | ` ${styleText("dim", runnerMessages.screenshot(path))}\n`, |
| 50 | ); |
| 51 | }, |
| 52 | |
| 53 | onFlowPass({ tests, durationMs, manifest }) { |
| 54 | const counts = |
| 55 | tests.total > 0 ? `${tests.passed}/${tests.total} tests ` : ""; |
| 56 | deps.stdout.write( |
| 57 | ` ${styleText("green", "✓")} ${counts}passed ${styleText( |
| 58 | "dim", |
| 59 | fmtDuration(durationMs), |
| 60 | )}\n`, |
| 61 | ); |
| 62 | if (manifest) deps.stdout.write(fmtStampLine(manifest)); |
| 63 | }, |
| 64 | |
| 65 | onFlowFail({ err, tests, durationMs, attempt, maxAttempts, manifest }) { |
| 66 | const errStr = formatErrorWithCause(err); |
| 67 | const [firstLine, ...restLines] = errStr.split("\n"); |
| 68 | const indent = " "; |
| 69 | const formatted = [ |
| 70 | styleText("red", `${indent}${firstLine}`), |
| 71 | ...restLines.map((line) => styleText("dim", `${indent}${line}`)), |
| 72 | ].join("\n"); |
| 73 | deps.stderr.write(`${formatted}\n\n`); |
| 74 | |
| 75 | const counts = |
| 76 | tests.total > 0 ? `${tests.passed}/${tests.total} tests ` : ""; |
| 77 | deps.stdout.write( |
| 78 | ` ${styleText("red", "✗")} ${counts}passed ${styleText( |
| 79 | "dim", |
| 80 | fmtDuration(durationMs), |
| 81 | )}\n`, |
| 82 | ); |
| 83 | if (manifest) deps.stdout.write(fmtStampLine(manifest)); |
| 84 |
no outgoing calls
no test coverage detected