Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions test-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# test-utils

Test server for running Tabi apps in tests.

## Installation

```typescript
import { TabiTestServer } from "@tabirun/app/test-utils";
```

## Usage

```typescript
Deno.test("GET /health returns 200", async () => {
const server = new TabiTestServer();

server.app.get("/health", (c) => c.json({ status: "ok" }));
server.start();

const res = await fetch(server.url("/health"));
assertEquals(res.status, 200);

await server.stop();
});
```

## API

- `new TabiTestServer()` - Create test server instance
- `app` - The underlying `TabiApp` instance
- `start(port?)` - Start server (uses random port if not specified)
- `url(path)` - Get HTTP URL for path
- `wsUrl(path)` - Get WebSocket URL for path
- `stop()` - Gracefully shutdown server

## Notes

- Uses port 0 by default to avoid "address in use" errors
- Always call `stop()` after tests to release resources
28 changes: 28 additions & 0 deletions type-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# type-utils

Type utilities for internal use.

## Installation

```typescript
import { type PublicOf } from "@tabirun/app/type-utils";
```

## Usage

```typescript
class MyClass {
private _secret = "hidden";
public name = "visible";
public greet() {
return "hello";
}
}

type MyPublicAPI = PublicOf<MyClass>;
// { name: string; greet: () => string }
```

## Types

- `PublicOf<T>` - Extracts public interface of a class or object