interface Console

Where a run's text goes: console, made injectable.

Every reporter line, every # diagnostic and the TAP document itself go through the run's Console instead of touching process.stdout. That is what makes "run these tests and print nothing" expressible, and what lets a caller point the built-in reporters at a buffer.

The same two channels the global has, and no more: severity lives on Notice.level, set by Reporter.info/warning/error. A Writable would drag in backpressure, encodings and a close lifecycle that nothing here has to think about.

This module imports nothing, on purpose. lib/tap, lib/setup, lib/commands/daemon and lib/api all need it, and lib/reporters already imports lib/tap — so a leaf is the only home that neither inverts a layer nor closes a cycle.

import { streamConsole } from './console.ts';

const lines: string[] = [];
streamConsole({ write: (text: string) => void lines.push(text) }).log('ok 1 Math | adds\n');
lines; // ['ok 1 Math | adds\n']

Methods

log(text: string): void

Writes to the primary stream — the TAP/spec/dot document itself.

error(text: string): void

Writes to the error stream. Diagnostics that must survive a swallowed stdout go here too.

Usage

import { type Console } from "lib/api/index.ts";