function start
start(
config: Config,
preload?: string[],
onOpen?: (session: ReplSession) => void
): Promise<ReplSession>

Starts a REPL for an assembled config: bundles qunitx and the preload files, serves it, opens a page on it, and attaches to that page over CDP.

preload is passed rather than read off config.fsTree because the two mean different things. The fsTree is what a RUN would execute — inputs plus package.json#qunitx.inputs — and a prompt that ran your whole suite before appearing is not what qunitx repl means. Only files named on this invocation are loaded.

onOpen fires once the page is up and ReplSession.loaded is known, before the preloaded files' own tests run. That ordering is the whole reason it exists: the CLI announces the session there, and without it the first thing a user saw was TAP from a session that had not introduced itself yet.

import * as Repl from './session.ts';

import type { Config } from '../types.ts';

// Defined, not invoked: launches a browser and binds a port.
async function open(config: Config) {
  await using session = await Repl.start(config, []);
  return session.url;
}

Parameters

config: Config
optional
preload: string[]
optional
onOpen: (session: ReplSession) => void

Return Type

Promise<ReplSession>

Usage

import { start } from "lib/repl/session.ts";