@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().

PackageDescription
@probitas-test/runnerUses reporters for output
probitasCLI that uses these reporters

Available Reporters

  • ListReporter - Detailed hierarchical output showing scenario and step names
  • JSONReporter - JSON output for machine-readable results

Installation

npm install @probitas-test/reporter

Classes

class

#JSONReporter

class JSONReporter implements Reporter
ImplementsReporter
Constructor
new JSONReporter(options: JSONReporterOptions)
NameDescription
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
onRunStart(scenarios: readonly ScenarioMetadata[]): Promise<void>

Called when the test run starts, before any scenarios execute.

Parameters
onScenarioEnd(scenario: ScenarioMetadata, result: ScenarioResult): Promise<void>

Called when scenario completes

Parameters
onScenarioStart(scenario: ScenarioMetadata): Promise<void>

Called when a scenario begins execution.

Parameters
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 value from step execution
  • If status is "failed" or "skipped": contains error information
Parameters
onStepStart(scenario: ScenarioMetadata, step: StepMetadata): Promise<void>

Called when step starts

Parameters
class

#ListReporter

class ListReporter implements Reporter
ImplementsReporter

Reporter 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.

NameDescription
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
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 value from step execution
  • If status is "failed" or "skipped": contains error information
Parameters

Interfaces

interface

#JSONReporterOptions

interface JSONReporterOptions extends WriterOptions
interface

#ListReporterOptions

interface ListReporterOptions extends WriterOptions

Options for ListReporter initialization.

NameDescription
cwdBase directory for making paths relative in output.
themeCustom theme for styling output.
Properties
  • cwd?string

    Base directory for making paths relative in output. If not provided, absolute paths are displayed as-is.

  • theme?Theme

    Custom theme for styling output. If not provided, uses defaultTheme (or noColorTheme if Deno.noColor is set).

interface

#ReporterOptions

interface ReporterOptions

Configuration 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;
NameDescription
cwdBase directory for making paths relative in output.
outputOutput stream for writing results.
themeCustom theme for styling output.
Properties
  • readonlycwd?string

    Base directory for making paths relative in output.

    If provided, absolute paths in source locations will be displayed relative to this directory.

  • readonlyoutput?WritableStream<any>

    Output stream for writing results.

  • readonlytheme?Theme

    Custom theme for styling output.

    If not provided, uses defaultTheme (or noColorTheme if Deno.noColor is true).

Search Documentation