Starts a watch session: builds once, runs once, then re-runs on every save until closed.
A running watch session.
-
abort(): Promise<void>
Cuts the current run short: the browser drops the rest of its queue and the run ends where it is, with
aborted: trueon its result. -
browser: Browser
Playwright's
Browserfor this session — unstable, playwright-core's type. -
close(): Promise<void>
Stops watching, closes the browser and server, and ends the iteration. Idempotent.
-
droppedEvents: number
How many events the feed dropped because a consumer fell behind.
0unless something stalls. -
esbuild: BuildContext | null
esbuild's incremental
BuildContext— unstable, esbuild's type. -
events(): Stream<RunEvent>
The fine-grained feed: every event of every run, flat and in order, until the session closes.
-
fileWatchers: Record<string, FSWatcher>
The live
fs.watchhandles keyed by watched path — unstable, and a PARTIAL view: the parent-directory watchers, rescan intervals and symlink pollers the session also owns are not in here. It answers "what is being watched", not "every handle the watcher holds". -
initial: RunResult
The initial run's result, available before anything has changed on disk.
-
latest: RunResult
The most recent run's result —
initialuntil something re-runs. -
page: Page
The page the suite runs in — unstable, playwright-core's type.
-
restart(patch?: SessionPatch): Promise<RunResult>
Tears the session's machinery down and boots it again — browser, page, server, esbuild context and watchers — then runs the suite once, resolving with that run's result.
- results(): Stream<RunResult>
-
run(files?: string[]): Promise<RunResult>
Re-runs now, optionally scoped to
files, and resolves with that run's result. -
runAll(): Promise<RunResult>
Runs the whole suite, dropping any line-target selectors this session was scoped to.
-
runFailed(): Promise<RunResult>
Re-runs the files that last failed, or repeats the last run when nothing has failed yet — saying so as an
infonotice on the result rather than silently doing something else. -
running: boolean
Whether a run is in flight right now.
-
url: string
Where the QUnit view is being served, e.g.
http://localhost:1234. -
webServer: HTTPServer
The HTTP + WebSocket server serving the bundle — unstable, this project's own
HTTPServerrather than a documented interface.
The options a WatchSession.restart may change.
Usage
import * as mod from "lib/api/watch.ts";