function run
run(
file: string,
options?: ScriptOptions
): Task<ScriptResult, ScriptFailure>

Runs ONE file as a plain script in a real browser — the API twin of qunitx run <file>, and the sibling of test, which runs a suite.

The script is bundled with esbuild and evaluated as a module in the page, so it gets a DOM, fetch against a real http://localhost origin, import.meta and top-level await. Its own console output goes to this process's stdout and stderr as it happens; the resolved value is the outcome, not the output.

A non-zero exit code is a result, not a rejectionok: false, the same way a red suite is a result for test. It rejects only when the script could not be run at all: no such file, a bundle that will not build, or a target that is not a single file.

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

// Defined, not invoked: launches a browser and executes the script.
async function seed() {
  const result = await run('scripts/seed.ts', { timeout: 30_000 });
  return result.ok ? 'seeded' : `exited ${result.exitCode}`;
}

Parameters

file: string
optional
options: ScriptOptions

Return Type

Usage

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