Beta
Test APIs programmatically
Test APIs programmatically
without ever leaving your code.
t-req is a utility-first HTTP client with standard .http files that work with
Vitest, Jest, and Bun test
— no proprietary DSLs, no vendor lock-in.
API Testing is Broken
Current tools force you to choose between convenience and control.
| Pain Point | The Problem |
|---|---|
| Vendor Lock-in | Your collections live in proprietary formats. Switching tools means starting over. |
| No Programmatic Access | Their stack, not yours. No programmatic API, no way to import into your test suite. |
| Yet Another DSL | jsonpath "$.id" exists when you
already know expect(body.id).toBeDefined() |
A Better Way
t-req gives you a programmatic API, your choice of test runner, and a standard file format.
Programmatic API
Import, Don't Install
createClient() gives you a JavaScript/TypeScript
API. Import directly into Vitest, Jest, Bun test, or any runner.
import { createClient } from '@t-req/core';
const client = createClient();
const response = await client.run('./api.http');
// Standard Response object
console.log(response.status);
console.log(await response.json()); Bring Your Own Test Runner
Your Assertions. Your Framework.
t-req returns standard Response objects.
Use expect(), assert, or any assertion library you already know.
import { createClient } from '@t-req/core';
import { expect, test } from 'vitest';
const client = createClient();
test('creates user', async () => {
const res = await client.run('./api.http');
expect(res.status).toBe(201);
}); import { createClient } from '@t-req/core';
const client = createClient();
test('creates user', async () => {
const res = await client.run('./api.http');
expect(res.status).toBe(201);
}); import { createClient } from '@t-req/core';
import { expect, test } from 'bun:test';
const client = createClient();
test('creates user', async () => {
const res = await client.run('./api.http');
expect(res.status).toBe(201);
}); See It In Action
Define your request, write your test, run with any test framework.
# @name getUser
GET {{baseUrl}}/users/{{userId}}
Authorization: Bearer {{token}} import { createClient } from '@t-req/core';
import { expect, test } from 'vitest';
const client = createClient();
test('get user returns 200', async () => {
const res = await client.run('./api.http');
expect(res.status).toBe(200);
const body = await res.json();
expect(body.id).toBeDefined();
}); $ vitest
✓ api.test.ts (1 test) 45ms
✓ get user returns 200 Quick Start
Get up and running in seconds.
Use the CLI
# 1. Initialize
treq init my-api
cd my-api
# 2. Install dependencies
npm install
# 3. Open TUI
treq open Or use as a library
npm install @t-req/core