function repl
repl(options?: UserRunOptions): Task<ReplSession, ReplFailure>

Opens a REPL against a live browser page and hands back the session.

The verb the CLI's qunitx repl is built on, and useful on its own wherever a page needs to be asked questions rather than tested: a scripted browser probe, a documentation example that must really run, a test for something that only exists in a real DOM.

inputs are preloaded modules, not a test target — each one's exports land on the page's globalThis, and any tests it registers run once as the session opens. Nothing else is loaded: unlike run(), package.json#qunitx.inputs is not a default here.

Lazy, like every verb in this API: nothing launches until the Task is awaited. Nothing is printed either, unless a reporter is asked for — tests typed at the prompt are reported through exactly the same reporters a run uses.

import { repl } from './repl.ts';

// Defined, not invoked: launches a browser.
async function measure() {
  await using session = await repl({ inputs: ['test/helpers.ts'] });
  const { output } = await session.eval('document.querySelector("#qunit-fixture").tagName');
  return output; // "'DIV'"
}

Parameters

optional
options: UserRunOptions

Return Type

repl(
preload: string | string[],
options?: UserRunOptions
): Task<ReplSession, ReplFailure>

The same session, with the preload named positionally: repl('test/helpers.ts', { port: 4000 }).

The shape every other verb takes, offered here so they read alike. The positional preload wins over any inputs in the options object.

Parameters

preload: string | string[]
optional
options: UserRunOptions

Return Type

Usage

import { repl } from "lib/api/repl.ts";