Runner Utilities

This part provides helper functions for the test runner.

Columns are parts of the code, grouped by process. Read top to bottom. Solid arrow: hands work over. Dashed: the reply. Purple: crosses between processes. Hook: work inside one part. Dashed boxes repeat. Hover a column name or a step for its full text.

MAIN PROCESSWORKER-FILE PROCESSMAIN PROCESSWORKER-FILE PROCESSMAIN PROCESSWORKER-FILE PROCESSLoop over project initializationLoop over file task creationLoop over suite executionLoop over child tasks in parallelResolve project definitionsPass CPU core countCreate queue limiterSubmit project initializationQueue initialization taskCreate placeholder tasksPass file pathsCreate file-suite taskCollect typecheck definitionsPass file for ID assignmentAssign child task IDsPass filter configurationApply filters to tasksCreate top-level suitePass empty suite contextCall with chain con…Build test API helpersPass chain flagsReturn callable APIAssign IDs recursivelyExecute files sequentiallyPass suite for partitioningPar…Execute child by kindSubmit test for limitingQueue test execution
Project Setup
Concurrency
File Mocking
Task Setup
Typecheck
Test Runner
API Chaining
Grouping
1Resolve and initialize projects — The system discovers configuration files and initializes project definitions, validating that each project has a unique name. It uses a whitelist of allowed command-line options that override inline test options, and determines concurrency based on available CPU cores defaulting to 5 if detection fails. If no projects are found, it throws an error with filter details and JSON definitions.
2Queue work within concurrency limits — The concurrency limiter creates a queue that holds tasks when the active count reaches the configured limit, using a first-in-first-out order. Tasks start asynchronously so any synchronous errors become rejections, and slots are released when tasks settle regardless of success or failure. A concurrency value of zero or less can cause the queue to wait forever.
3Replace files with placeholder tasks — The system replaces stored file paths with local placeholder file tasks that act as stubs before actual test collection begins. Each placeholder gets a stable ID generated from the root-relative path, an empty task list, and a fresh file context. These placeholders are kept for console log association and do not purge old descendant IDs.
4Collect typecheck test definitions — The system statically analyzes transformed source code to find test definitions, recognizing test functions through various wrapper patterns while skipping conditional wrapper calls. It builds nested tasks from source ranges, inheriting suite modes, and uses literal text for test names. Null transforms return null and no definitions are collected.
5Assign IDs and apply filters — Each child task receives an ID built from its parent ID and zero-based index, with the pattern recursing through all suites in task order. Task modes are then mutated based on exclusivity flags, name patterns, and location filters, while propagating skip and todo states from parents. Unmatched requested test locations are recorded as errors.
6Build chainable test API — An unnamed top-level suite collector is created so tests have no parent suite, and the chainable test API is built with helper methods for iteration, conditional skipping, conditional running, scoping, and extension. Chain flags including concurrent, sequential, skip, only, todo, and fails create copied invocation contexts when accessed. The extend helper merges fixtures and sets a default timeout from configuration.
7Assign IDs to collected tasks — The system assigns child task IDs from the parent ID and child index recursively, ensuring each test has a unique identifier within its suite hierarchy. This happens after collection whenever suite IDs need calculation, recursing through suites in task order. The callable API with its chain flag properties creates copied invocation contexts for test definition.
8Execute files and partition suites — Collected files are executed sequentially, initializing a shared concurrency limiter from the maximum concurrency setting. Empty files fail with an error unless pass with no tests is set or errors already exist. Each suite's children are partitioned into consecutive groups with equal concurrent flags, where false and undefined are treated as separate values.
9Execute child tasks by kind — Each child task is executed according to its kind, with tests passing through a maximum concurrency limiter before running and suites calling the suite runner recursively. Concurrent groups run in parallel using promise all, while others run sequentially with optional seeded shuffle. Other task kinds produce undefined results.
10Release concurrency slots — The concurrency limiter releases a slot and wakes the next queued task when a test completes, decrementing the active count. The head callback is invoked, the queue advances, and the tail clears when the queue empties. This ensures queued tests start as slots become available.
STEP · hover for full text