function openSession
openSession(options: SessionOptions & { watch: true; }): Task<WatchSession, RunFailure>

With watch: true, the DURABLE shape: one page behind a stable WatchSession.url, kept open with the rerun verbs and file watching, exactly as watch gives you.

Not the same session with watchers bolted on — the other execution shape. This one bundles every file together and serves one page; the form below splits them across as many pages as there are cores and is spent after a single run. watch() is the shorter spelling of this overload.

import { openSession } from './session.ts';

// Defined, not invoked: holds a browser and a port open.
async function serve() {
  const session = await openSession({ inputs: ['test/'], watch: true });
  return session.url; // 'http://localhost:1234'
}

Parameters

options: SessionOptions & { watch: true; }

Return Type

openSession(
target: string | string[],
options: SessionOptions & { watch: true; }
): Task<WatchSession, RunFailure>

The durable shape with the target named positionally: openSession('test/', { watch: true }).

Parameters

target: string | string[]
options: SessionOptions & { watch: true; }

Return Type

openSession(options?: SessionOptions): Task<TestSession, RunFailure>

Starts a single run you can watch happen, rather than one you wait out.

Use it when the run's progress is the point — a progress bar, a live log, a UI that shows tests as they finish. When only the outcome matters, run() is the smaller thing: it allocates none of this machinery and hands back the same RunResult.

Lazy twice over, and for two different reasons: the Task does nothing until awaited (like every other verb here), and the session it resolves to does not start the run until it is consumed (so the event feed cannot fall behind).

import { openSession } from './session.ts';

// Defined, not invoked: launches a browser and runs the project's tests.
async function countAsTheyFinish() {
  await using session = await openSession({ inputs: ['test/'] });
  let finished = 0;
  for await (const event of session) if (event.kind === 'test') finished++;
  return finished;
}

Parameters

optional
options: SessionOptions

Return Type

openSession(
target: string | string[],
options?: SessionOptions
): Task<TestSession, RunFailure>

The one-shot shape with the target named positionally: openSession('test/', { filter: 'Cart' }).

Parameters

target: string | string[]
optional
options: SessionOptions

Return Type