@probitas-test/reporter
Test result reporting and formatting for Probitas.
This package provides multiple reporter implementations for formatting and
displaying test execution results. All reporters implement the Reporter
interface from @probitas-test/runner and can be passed to ScenarioRunner.run().
Links
- GitHub Repository
- @probitas-test/probitas - Main package (recommended for most users)
Related Packages
| Package | Description |
|---|---|
| @probitas-test/runner | Uses reporters for output |
| probitas | CLI that uses these reporters |
Available Reporters
ListReporter- Detailed hierarchical output showing scenario and step namesJSONReporter- JSON output for machine-readable results
Installation
npm install @probitas-test/reporterClasses
#JSONReporter
class JSONReporter implements ReporterReporterConstructor
new JSONReporter(options: JSONReporterOptions)| Name | Description |
|---|---|
onRunEnd() | Called when test run completes |
onRunStart() | Called when the test run starts, before any scenarios execute. |
onScenarioEnd() | Called when scenario completes |
onScenarioStart() | Called when a scenario begins execution. |
onStepEnd() | Called when step completes (passed, failed, or skipped). |
onStepStart() | Called when step starts |
Methods
onRunEnd(
scenarios: readonly ScenarioMetadata[],
result: RunResult,
): Promise<void>Called when test run completes
Parameters
scenariosreadonly ScenarioMetadata[]resultRunResult
onRunStart(scenarios: readonly ScenarioMetadata[]): Promise<void>Called when the test run starts, before any scenarios execute.
Parameters
scenariosreadonly ScenarioMetadata[]
onScenarioEnd(scenario: ScenarioMetadata, result: ScenarioResult): Promise<void>Called when scenario completes
Parameters
scenarioScenarioMetadataresultScenarioResult
onScenarioStart(scenario: ScenarioMetadata): Promise<void>Called when a scenario begins execution.
Parameters
scenarioScenarioMetadata
onStepEnd(
scenario: ScenarioMetadata,
step: StepMetadata,
result: StepResult,
): Promise<void>Called when step completes (passed, failed, or skipped).
The result contains status-specific information:
- If status is "passed": contains
valuefrom step execution - If status is "failed" or "skipped": contains
errorinformation
Parameters
scenarioScenarioMetadatastepStepMetadataresultStepResult
onStepStart(scenario: ScenarioMetadata, step: StepMetadata): Promise<void>Called when step starts
Parameters
scenarioScenarioMetadatastepStepMetadata
#ListReporter
class ListReporter implements ReporterReporterReporter that outputs test results in a flat list format.
Features:
- Real-time per-step output as tests execute
- Status indicators (✓ passed, ✗ failed, ⊘ skipped)
- Origin location information
- Execution timing for each step
- Skip reasons for conditional skips
- Error messages and stack traces for failures
- Summary statistics
- Semantic coloring via Theme
Examples
import { ListReporter } from "@probitas-test/reporter";
const reporter = new ListReporter();
void reporter;
// Output:
// ✓ Login scenario > Step that passes (test.ts:15) [10.000ms]
// ✓ Login scenario > Another step (test.ts:20) [5.000ms]
// ✗ Payment scenario > Process payment (test.ts:50) [25.000ms]
// Error: Insufficient funds
// at checkout (test.ts:52)
//
// Summary
// ✓ 1 scenarios passed
// ✗ 1 scenarios failed
Constructor
new ListReporter(options: ListReporterOptions)Create a new ListReporter.
| Name | Description |
|---|---|
onRunEnd() | Called when run ends - output summary |
onStepEnd() | Called when step completes (passed, failed, or skipped). |
Methods
onRunEnd(
scenarios: readonly ScenarioMetadata[],
result: RunResult,
): Promise<void>Called when run ends - output summary
Parameters
scenariosreadonly ScenarioMetadata[]resultRunResult
onStepEnd(
scenario: ScenarioMetadata,
step: StepMetadata,
result: StepResult,
): Promise<void>Called when step completes (passed, failed, or skipped).
The result contains status-specific information:
- If status is "passed": contains
valuefrom step execution - If status is "failed" or "skipped": contains
errorinformation
Parameters
scenarioScenarioMetadatastepStepMetadataresultStepResult
Interfaces
#JSONReporterOptions
interface JSONReporterOptions extends WriterOptions#ListReporterOptions
interface ListReporterOptions extends WriterOptionsOptions for ListReporter initialization.
| Name | Description |
|---|---|
cwd | Base directory for making paths relative in output. |
theme | Custom theme for styling output. |
Properties
cwd?stringBase directory for making paths relative in output. If not provided, absolute paths are displayed as-is.
theme?ThemeCustom theme for styling output. If not provided, uses defaultTheme (or noColorTheme if Deno.noColor is set).
#ReporterOptions
interface ReporterOptionsConfiguration options for reporter initialization.
Examples
Basic usage
import { ListReporter } from "@probitas-test/reporter";
const reporter = new ListReporter({
output: Deno.stdout.writable
});
void reporter;
Custom output stream (using a buffer)
import { ListReporter } from "@probitas-test/reporter";
import { Buffer } from "@std/streams";
const buffer = new Buffer();
const reporter = new ListReporter({
output: buffer.writable
});
void reporter;
| Name | Description |
|---|---|
cwd | Base directory for making paths relative in output. |
output | Output stream for writing results. |
theme | Custom theme for styling output. |
Properties
- readonly
cwd?stringBase directory for making paths relative in output.
If provided, absolute paths in source locations will be displayed relative to this directory.
- readonly
output?WritableStream<any>Output stream for writing results.
- readonly
theme?ThemeCustom theme for styling output.
If not provided, uses
defaultTheme(ornoColorThemeifDeno.noColoris true).
