Classifies raw positional targets into flags, exactly as the CLI does with argv positionals:
.html fixtures become htmlPaths, a trailing #34/:34 becomes a lineTargets entry, and
everything else is an absolute path in inputs (deduplicated) plus a wholeInputPaths mention.
Parses an argv into a qunitx flag object (inputs, debug, watch, failFast, timeout, output, port, before, after).
The flag object a successful parse() carries — CLI flags only, before package.json merge.
-
after: string | false
--after: module run after the tests, orfalseto disable a configured one. -
before: string | false
--before: module run before the tests, orfalseto disable a configured one. -
browser: "chromium" | "firefox" | "webkit"
--browser: the engine to run in. -
changedSince: string
--since/--changed: run only files whose transitive imports changed since this git ref. -
coverage: boolean
--coverage: collect V8 line coverage. -
coverageFormats: string[]
Artifact formats beyond the terminal summary (
lcov,html). -
debug: boolean
--debug/--console: print the server URL and forward the page's console. -
extensions: string[]
--extensions: file extensions treated as test files. -
failFast: boolean
--failFast: stop at the first failing test. -
filter: string
-t/--filter/-m/--module/-n: the one test-name matcher, in QUnit's own semantics. -
htmlPaths: string[]
Positional
.htmlfixtures the test bundle is injected into. -
inputs: string[]
Absolute paths of the test targets, deduplicated.
.htmlfixtures and#linesuffixes are split out intohtmlPathsandlineTargetsrather than kept here. -
junit: boolean | string
--junit: write a JUnit report.trueuses the default path; a string overrides it. -
lineTargets: Record<string, number[]>
Absolute path → the
#34line targets given for it. -
onlyFailed: boolean
--only-failed/-f: run only the files that failed on the previous run. -
open: boolean | string
--open/-o: open the output in a browser; a string names a specific binary. -
output: string
--output: directory for the compiled bundle and HTML. -
port: number
--port/-p: the port the local test server listens on. -
portExplicit: boolean
truewhen--portwas given explicitly, so a busy port fails instead of incrementing. -
reporter: ReporterName
--reporter/-r: the single stdout format. -
search: string | true
--search/--printmode: the expression to preview, ortrueto list everything. -
timeout: number
--timeout: milliseconds a single test may take before the run is declared stalled. -
watch: boolean
--watch/-w: re-run on every save instead of exiting after one run. -
wholeInputPaths: string[]
Absolute paths mentioned WITHOUT a line target — whole-file requests that supersede a line target.
Every way parse() can reject its input.
A flag was given a value this parser will not accept.
Usage
import * as mod from "lib/args/parse.ts";