6.7 KiB
@git.zone/tstest
🚀 Multi-runtime TypeScript test runner with beautiful output and intelligent test orchestration
Installation
# tstest is the main CLI entry point
pnpm install --save-dev @git.zone/tstest
Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit community.foss.global/. This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a code.foss.global/ account to submit Pull Requests directly.
Overview
This is the core test runner module of @git.zone/tstest. It provides the CLI, test discovery, multi-runtime execution, TAP output parsing, structured logging, and test orchestration. It ties together the entire testing pipeline — from finding test files to dispatching them across Node.js, Chromium, Deno, Bun, and Docker runtimes.
Key Features
- 🔍 Smart Test Discovery — Glob patterns, directory scanning, and single-file mode
- 🏃 Multi-Runtime Execution — Node.js, Chromium, Deno, Bun, and Docker adapters
- 📊 TAP Protocol Parsing — Full Protocol V2 support with structured metadata
- 🎨 Rich Logging — Color-coded output, JSON mode, per-file log files, diff tracking
- ⚡ Parallel Execution — File-level parallel groups via
*.para__N.*naming - 👀 Watch Mode — Re-run tests on file changes with debouncing
- 🏷️ Tag Filtering — Run only tests matching specific tags
- ⏱️ Timeout Management — Per-file timeouts with process tree termination
- 📝 Test File Directives — Inline comments to configure runtime permissions and flags
- 🔄 Before Scripts —
package.json-based lifecycle hooks (test:before,test:before:testfile) - 🐳 Docker Testing — Run tests inside Docker containers via
*.docker.shfiles - 🔀 Legacy Migration — Automatic rename of
.browser.ts→.chromium.tspatterns
Architecture
Runtime Adapter System
Each runtime is implemented as a RuntimeAdapter with a unified interface:
| Adapter | Runtime | How It Executes Tests |
|---|---|---|
NodeRuntimeAdapter |
Node.js | Spawns via @git.zone/tsrun, streams TAP output |
ChromiumRuntimeAdapter |
Chromium | Bundles with esbuild, serves over HTTP, communicates via WebSocket |
DenoRuntimeAdapter |
Deno | Runs deno run with configurable permissions |
BunRuntimeAdapter |
Bun | Runs bun run with auto-discovered config |
DockerRuntimeAdapter |
Docker | Builds image from Dockerfile, runs docker run |
Test File Naming Convention
Test filenames determine which runtime(s) execute them:
| Pattern | Runtimes |
|---|---|
*.ts |
Node.js (default) |
*.node.ts |
Node.js only |
*.chromium.ts |
Chromium browser |
*.deno.ts |
Deno |
*.bun.ts |
Bun |
*.all.ts |
All runtimes |
*.node+chromium.ts |
Node.js + Chromium |
*.para__N.ts |
Parallel group N |
*.docker.sh |
Docker container |
Execution Flow
- Discovery —
TestDirectoryscans for test files based on mode (directory/file/glob) - Grouping — Files are split into serial and parallel groups (via
*.para__N.*naming) - Before Scripts —
test:before/test:before:testfilefrompackage.jsonrun - Dispatch — Each file is parsed for runtime specifiers and directives, then routed to the appropriate
RuntimeAdapter - Parsing —
TapParserprocesses TAP output using Protocol V2, tracking results and events - Aggregation —
TapCombinatormerges results from all test files - Reporting —
TsTestLoggeroutputs structured results (console, JSON, or log files)
Inline Directives
Test files can include comment directives at the top (before imports) to configure runtime behavior:
// tstest:deno:allowAll
// tstest:node:flag:--max-old-space-size=4096
// tstest:env:MY_VAR=value
import { tap, expect } from '@git.zone/tstest/tapbundle';
Directives in 00init.ts files apply to all tests in that directory and are merged with per-file directives.
CLI Usage
# Directory mode — scan recursively for test files
tstest test/
# File mode — run a single test
tstest test/test.math.ts
# Glob mode — match patterns
tstest "test/**/*.node.ts"
Options
| Flag | Description |
|---|---|
--verbose, -v |
Show all console output from tests |
--quiet, -q |
Minimal output for CI |
--json |
Machine-readable JSON output |
--logfile |
Write per-file logs to .nogit/testlogs/ |
--tags <tags> |
Filter tests by comma-separated tags |
--timeout <sec> |
Per-file timeout in seconds |
--startFrom <n> |
Start from file number N |
--stopAt <n> |
Stop at file number N |
--watch, -w |
Re-run tests on file changes |
--watch-ignore <pat> |
Comma-separated ignore patterns |
--no-color |
Disable ANSI colors |
Public API
import { runCli, TestExecutionMode } from '@git.zone/tstest';
| Export | Type | Description |
|---|---|---|
runCli() |
async function |
CLI entry point — parses process.argv and runs tests |
TestExecutionMode |
enum |
DIRECTORY, FILE, or GLOB |
License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the license file.
Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
Company Information
Task Venture Capital GmbH Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.