lib/commands/generate.ts

Functions

f
generateTestFiles(): Promise<void>

Generates a new test file from the boilerplate template.

lib/commands/help.ts

Functions

f
displayHelpOutput(): void

Prints qunitx-cli usage information to stdout.

lib/commands/init.ts

Functions

f
initializeProject(): Promise<void>

Bootstraps a new qunitx project: writes the test HTML template, updates package.json, and optionally writes tsconfig.json.

lib/commands/run.ts

Functions

f
run(config: Config): Promise<void>

Runs qunitx tests in headless Chrome, either in watch mode or concurrent batch mode.

lib/commands/run/tests-in-browser.ts

Functions

f
buildTestBundle(
config: Config,
cachedContent: CachedContent
): Promise<void>

Pre-builds the esbuild bundle for all test files and caches the result in cachedContent.

lib/servers/http.ts

Classes

c
HTTPServer()

Minimal HTTP + WebSocket server used to serve test bundles and push reload events.

Interfaces

Type Aliases

T
Middleware = (
req: http.IncomingMessage,
res: http.ServerResponse,
next: () => void
) => void

Middleware function signature — call next() to continue the chain.

T
RouteHandler = (
req: http.IncomingMessage,
res: http.ServerResponse
) => void | Promise<void>

Route handler function signature for registered GET/POST/etc. routes.

Variables

v
MIME_TYPES: Record<string, string>

Map of file extensions to their corresponding MIME type strings.

lib/setup/bind-server-to-port.ts

Functions

f
bindServerToPort(
server: HTTPServer,
config: { port: number; }
): Promise<HTTPServer>

Binds an HTTPServer to an OS-assigned port and writes the resolved port back to config.port.

lib/setup/browser.ts

Functions

f
launchBrowser(config: Config): Promise<Browser>

Launches a browser for the given config.browser type. For chromium: connects via CDP to the pre-launched Chrome (fast path) or falls back to chromium.launch() if pre-launch failed. For firefox/webkit: uses playwright's standard launch (requires npx playwright install [browser]).

f
setupBrowser(
config: Config,
cachedContent: CachedContent,
existingBrowser?: Browser | null
): Promise<Connections>

Launches a Playwright browser (or reuses an existing one), starts the web server, and returns the page/server/browser connection object.

lib/setup/config.ts

Functions

f
setupConfig(): Promise<Config>

Builds the merged qunitx config from package.json settings and CLI flags.

lib/setup/file-watcher.ts

Functions

f
handleWatchEvent(
config: Config,
extensions: string[],
event: string,
filePath: string,
onEventFunc: (
event: string,
file: string
) => unknown
,
onFinishFunc: ((
path: string,
event: string
) => void) | null | undefined
): void

Routes a file-system event to fsTree mutation and optional rebuild trigger. unlinkDir bypasses the extension filter so deleted directories always clean up fsTree.

f
mutateFSTree(
fsTree: FSTree,
event: string,
path: string
): void

Mutates fsTree in place based on a chokidar file-system event.

f
setupFileWatchers(
testFileLookupPaths: string[],
config: Config,
onEventFunc: (
event: string,
file: string
) => unknown
,
onFinishFunc: ((
path: string,
event: string
) => void) | null | undefined
): { fileWatchers: Record<string, FSWatcher>; killFileWatchers: () => Record<string, FSWatcher>; }

Starts fs.watch watchers for each lookup path and calls onEventFunc on JS/TS file changes, debounced via a flag. Uses config.fsTree to distinguish unlink (tracked file) from unlinkDir (directory) on deletion.

lib/setup/fs-tree.ts

Functions

f
buildFSTree(
fileAbsolutePaths: string[],
config?: { extensions?: string[]; }
): Promise<FSTree>

Resolves an array of file paths, directories, or glob patterns into a flat { absolutePath: null } map.

lib/setup/keyboard-events.ts

Functions

f
setupKeyboardEvents(
config: Config,
cachedContent: CachedContent,
connections: Connections
): void

Registers watch-mode keyboard shortcuts: qq to abort, qa to run all, qf for last failed, ql for last run.

lib/setup/test-file-paths.ts

Functions

f
setupTestFilePaths(
_projectRoot: string,
inputs: string[]
): string[]

Deduplicates a list of file, folder, and glob inputs so that more-specific paths covered by broader ones are removed.

lib/setup/web-server.ts

Functions

f
setupWebServer(
config: Config,
cachedContent: CachedContent
): HTTPServer

Creates and returns an HTTPServer with routes for the test HTML, filtered test page, and static assets, plus a WebSocket handler that streams TAP events.

lib/setup/write-output-static-files.ts

Functions

f
writeOutputStaticFiles(
unnamed 0: { projectRoot: string; output: string; },
cachedContent: CachedContent
): Promise<void>

Copies static HTML files and referenced assets from the project into the configured output directory.

lib/tap/display-final-result.ts

Functions

f
TAPDisplayFinalResult(
unnamed 0: Counter,
timeTaken: number
): void

Prints the TAP plan line and test-run summary (total, pass, skip, fail, duration).

lib/tap/display-test-result.ts

Functions

f
TAPDisplayTestResult(
COUNTER: Counter,
details: TestDetails
): void

Formats and prints a single QUnit testEnd event as a TAP ok/not ok line with optional YAML failure block.

Interfaces

lib/tap/dump-yaml.ts

Functions

f
dumpYaml(unnamed 0: { name: string; actual: unknown; expected: unknown; message: string | null; stack: string | null; at: string | null; }): string

Serializes the fixed TAP assertion object to a YAML string. Uses a template literal (no Object.entries overhead) for the known top-level keys.

lib/types.ts
lib/utils/chromium-args.ts

Variables

v
default: string[]

Launch args passed to Chromium for both the CDP pre-launch spawn and the playwright fallback launch.

lib/utils/color.ts

Functions

f
createColors(enabled: boolean)

Creates a set of ANSI color helpers with coloring enabled or disabled.

f
magenta(text?: string): string | MagentaReturn
2 overloads

ANSI magenta text. Call without arguments to chain: magenta().bold(text).

Interfaces

lib/utils/early-chrome.ts

Variables

v
earlyBrowserPromise

Resolves to { proc, cdpEndpoint } when Chrome is pre-launched and ready, or null if pre-launch was skipped (non-run command or non-chromium browser).

lib/utils/find-chrome.ts

Functions

f
findChrome(): Promise<string | null>

Resolves the Chrome/Chromium executable path. Returns a Promise for API compatibility with callers, but the resolution is synchronous.

lib/utils/find-internal-assets-from-html.ts

Functions

f
findInternalAssetsFromHTML(htmlContent: string): string[]

Parses an HTML string and returns all internal (non-absolute-URL) <script src> and <link href> paths.

lib/utils/find-project-root.ts

Functions

f
findProjectRoot(): Promise<string>

Walks up parent directories from cwd to find the nearest package.json and returns its directory path.

lib/utils/indent-string.ts

Functions

f
indentString(
string: string,
count?: number,
options?: { indent?: string; includeEmptyLines?: boolean; }
): string

Prepends count repetitions of indent (default: one space) to each non-empty line of string.

lib/utils/listen-to-keyboard-key.ts

Functions

f
listenToKeyboardKey(
inputString: string,
closure: (input: string) => void,
options?: { caseSensitive: boolean; }
): void

Registers a stdin listener that fires closure when the user types inputString (case-insensitive by default).

lib/utils/parse-cli-flags.ts

Functions

f
parseCliFlags(projectRoot: string): ParsedFlags

Parses process.argv into a qunitx flag object (inputs, debug, watch, failFast, timeout, output, port, before, after).

Interfaces

lib/utils/path-exists.ts

Functions

f
pathExists(path: string): Promise<boolean>

Returns true if the given filesystem path is accessible, false otherwise.

lib/utils/perf-logger.ts

Functions

f
perfLog(
label: string,
...details: unknown[]
): void

Writes a timestamped perf trace line to stderr when --trace-perf is active.

lib/utils/pre-launch-chrome.ts

Functions

f
preLaunchChrome(
chromePath: string | null | undefined,
args: string[]
): Promise<EarlyChrome | null>

Spawns a headless Chrome process with remote-debugging-port=0 and resolves once the CDP WebSocket endpoint is printed to stderr. Returns null if Chrome is unavailable or fails to start, so callers can fall back to playwright's normal launch.

lib/utils/read-boilerplate.ts

Functions

f
readBoilerplate(relativePath: string): Promise<string>

Reads a boilerplate file by relative path, using the SEA asset store when running as a Node.js binary.

lib/utils/resolve-port-number-for.ts

Functions

f
resolvePortNumberFor(portNumber: number): Promise<number>

Returns portNumber if it is free, otherwise recursively tries portNumber + 1 until a free port is found.

lib/utils/run-user-module.ts

Functions

f
runUserModule(
modulePath: string,
params: unknown,
scriptPosition: string
): Promise<void>

Dynamically imports modulePath and calls its default export with params; exits with code 1 on error.

lib/utils/search-in-parent-directories.ts

Functions

f
default(
directory: string,
targetEntry: string
): Promise<string | undefined>

Recursively searches directory and its ancestors for a file or folder named targetEntry; returns the absolute path or undefined.

lib/utils/time-counter.ts

Functions

f
timeCounter(): { startTime: Date; stop: () => number; }

Returns a timer object with a startTime Date and a stop() method that returns elapsed milliseconds.

README.md

qunitx-cli