Open Test AdapterA generic VS Code Test Explorer extension that delegates test discovery and execution to an external adapter script. The extension is framework-agnostic — any test framework can integrate by implementing a simple JSON protocol. Features
Quick Start
Architecture
The extension spawns your adapter script as a child process using the configured runtime (bun or node). It sends commands via CLI arguments and reads structured JSON from stdout. The extension never touches your test framework directly.
Adapter Protocol
Your adapter script must handle two CLI commands and write JSON to stdout. Command:
|
| Setting | Description | Default |
|---|---|---|
openTestAdapter.adapterScript |
Path to the adapter script (absolute, or relative to the first workspace folder) | FixtureTestAdapter.ts |
openTestAdapter.runtime |
Runtime executable: bun, node, or a full path. If empty, auto-detects ./node_modules/bun/bin/bun.exe |
"" |
openTestAdapter.watchPatterns |
Glob patterns (relative to workspace) to watch — triggers re-discovery on file changes | [] |
openTestAdapter.browserUrl |
URL pattern for browser test execution. Use {tests} as placeholder for test IDs |
"" |
openTestAdapter.browserDebugPort |
Chrome DevTools Protocol port for browser communication | 9222 |
openTestAdapter.browserExecutable |
Path to Chrome or Edge. If empty, auto-detects from common install locations | "" |
Runtime: Bun vs Node
The extension supports both bun and node as runtimes:
| Bun | Node | |
|---|---|---|
| Config | "runtime": "bun" or leave empty (auto-detected) |
"runtime": "node" |
| TypeScript | Native .ts support, no build step |
Requires tsx, ts-node, or pre-compiled .js |
| Debugging | Uses the Bun VS Code extension | Uses the built-in Node.js debugger |
| Speed | Faster startup | Wider compatibility |
Browser Testing
The extension can run and debug tests directly in a browser (Chrome or Edge) — no Playwright or Puppeteer required. The extension communicates with the browser via the Chrome DevTools Protocol (CDP), which is built into every Chromium-based browser.
How It Works
sequenceDiagram
participant UI as Test Explorer
participant E as Extension
participant B as Browser (Chrome/Edge)
participant P as Your Test Page
UI->>E: Click "Run (Browser)"
E->>B: Launch with --remote-debugging-port
B->>P: Navigate to browserUrl?tests=id1,id2
P->>P: Run tests
P->>P: document.title = "DONE:" + JSON.stringify(results)
E->>B: Poll GET /json (CDP)
B-->>E: Tab title contains "DONE:..."
E->>UI: Parse results, mark pass/fail/error
Run Profiles
The extension provides four run profiles in the Test Explorer dropdown:
| Profile | Runtime | Headless | Debugger |
|---|---|---|---|
| Run | bun / node | N/A | None |
| Debug | bun / node | N/A | bun / Node.js debugger |
| Run (Browser) | Chrome / Edge | Yes | None |
| Debug (Browser) | Chrome / Edge | No | Chrome DevTools + VS Code |
Browser Result Convention
When tests complete, the test page must signal results by setting document.title:
// In your test page (browser):
const results = [
{ testId: "MathTests.additionTest", status: "passed", duration: 5 },
{ testId: "MathTests.divisionByZeroTest", status: "failed", duration: 3, error: "Expected Error" }
];
document.title = "DONE:" + JSON.stringify(results);
The results array uses the same RunResult format as the process-based adapter. The extension polls the browser's CDP endpoint and detects the title change to collect results.
Setting Up Browser Testing
Step 1: Configure the browser URL in your workspace settings:
{
"openTestAdapter.browserUrl": "http://localhost:5173/tests?tests={tests}"
}
The {tests} placeholder is replaced with comma-separated test IDs (e.g. MathTests.additionTest,MathTests.divisionByZeroTest).
Step 2: Create a test page that:
- Reads test IDs from the URL (e.g. from the
testsquery parameter) - Runs the requested tests using your framework
- Sets
document.title = "DONE:" + JSON.stringify(results)when complete
Step 3: Start your dev server (e.g. npm run dev for Vite) so the browser URL is reachable.
Step 4: Select "Run (Browser)" or "Debug (Browser)" from the Test Explorer profile dropdown and click play.
Browser Auto-Detection
The extension auto-detects installed browsers in this order:
- Microsoft Edge (always available on Windows 11)
- Google Chrome
Override with openTestAdapter.browserExecutable if needed.
Development
Scripts
| Script | Description |
|---|---|
npm run build |
Compile TypeScript |
npm run deploy |
Build, auto-increment version, package .vsix, and install into VS Code |
npm run publish |
Deploy + publish to VS Code Marketplace (requires VsCodeMarketplaceAccessToken env var) |
Publishing
export VsCodeMarketplaceAccessToken=your-pat-here
npm run publish
Troubleshooting
Tests not appearing: Check the adapter script path in settings. Run bun <adapterScript> discover manually to verify it outputs valid JSON.
Tests spin endlessly: The adapter process isn't exiting. Ensure any timers or open handles are cleaned up after execution.
All tests show as errored with "No result received": The testId in the run output doesn't match the discovery ID. The format must be FixtureName.testName.
Debug breakpoints don't bind: Make sure you have the correct debugger extension installed — Bun for VS Code for bun, or the built-in debugger for node.
Browser tests time out: Ensure your dev server is running and the browserUrl is reachable. Verify your test page sets document.title = "DONE:" + JSON.stringify(results) when tests complete.
Browser not found: Set openTestAdapter.browserExecutable to the full path of your Chrome or Edge executable.
CDP port conflict: If port 9222 is already in use, change openTestAdapter.browserDebugPort to another port.
License
Publish
https://marketplace.visualstudio.com/manage/publishers/AppGates?auth_redirect=True