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
7 changes: 4 additions & 3 deletions .github/workflows/web-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build blog content
run: pnpm --filter madea-blog-core build

- name: Build web
run: pnpm build:web

Expand All @@ -57,7 +60,5 @@ jobs:
uses: ./integrations/github-action
with:
skip-install: true
start: pnpm --filter @yapi/web start --port 3000
wait-on: http://localhost:3000/healthz
command: yapi test ./apps/web/yapi -a -p 16
command: yapi test ./apps/web/yapi --start="pnpm --filter @yapi/web start --port 3000"

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,46 @@ See the [action documentation](https://github.com/jamierpond/yapi/tree/main/acti

-----

## 🚀 Integrated Test Server

Run tests locally with automatic server lifecycle management. Configure in `yapi.config.yml`:

```yaml
yapi: v1

test:
start: "npm run dev"
wait_on:
- "http://localhost:3000/healthz"
timeout: 60s
parallel: 8

environments:
local:
url: http://localhost:3000
```

Now `yapi test` will automatically:
1. Start your dev server
2. Wait for health checks to pass
3. Run all tests
4. Kill the server when done

**Supported health check protocols:**
- `http://` / `https://` - HTTP health endpoints (expects 2xx)
- `grpc://` / `grpcs://` - gRPC health check protocol
- `tcp://` - TCP connection check (databases, etc.)

**CLI flags:**
```bash
yapi test ./tests # Uses config from yapi.config.yml
yapi test ./tests --no-start # Skip server startup (already running)
yapi test ./tests --start "npm start" --wait-on "http://localhost:4000/health"
yapi test ./tests --verbose # See server output
```

-----

## 🧠 Editor Integration (LSP)

Unlike other API clients, **yapi** ships with a **full LSP implementation** out of the box. Your editor becomes an intelligent API development environment with real-time validation, autocompletion, and inline execution.
Expand Down
65 changes: 65 additions & 0 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,71 @@ chain:

---

## E) Integrated Test Server

Automatically start your dev server, wait for health checks, run tests, and clean up. Configure in `yapi.config.yml`:

```yaml
yapi: v1

test:
start: "npm run dev"
wait_on:
- "http://localhost:3000/healthz"
- "grpc://localhost:50051"
timeout: 60s
parallel: 8
directory: "./tests"

environments:
local:
url: http://localhost:3000
```

### Running with Integrated Server

```bash
# Automatically starts server, waits for health, runs tests, kills server
yapi test

# Skip server startup (server already running)
yapi test --no-start

# Override config from CLI
yapi test --start "npm start" --wait-on "http://localhost:4000/health"

# See server stdout/stderr
yapi test --verbose
```

### Health Check Protocols

| Protocol | URL Format | Behavior |
|----------|------------|----------|
| HTTP/HTTPS | `http://localhost:3000/healthz` | Poll until 2xx response |
| gRPC | `grpc://localhost:50051` | Uses `grpc.health.v1.Health/Check` |
| TCP | `tcp://localhost:5432` | Poll until connection succeeds |

### Local vs CI Parity

The same workflow works locally and in CI:

**Local development:**
```bash
yapi test # starts server, runs tests, cleans up
```

**GitHub Actions:**
```yaml
- uses: jamierpond/yapi/action@main
with:
start: npm run dev
wait-on: http://localhost:3000/healthz
command: yapi test -a
```

---

## Commands Reference

| Command | Description |
Expand Down
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"test:node": "vitest run --config vitest.config.node.mts",
"test:browser": "vitest run --config vitest.config.browser.mts",
"test:watch:node": "vitest --config vitest.config.node.mts",
"test:watch:browser": "vitest --config vitest.config.browser.mts"
"test:watch:browser": "vitest --config vitest.config.browser.mts",
"test:yapi": "yapi test ./yapi"
},
"dependencies": {
"@monaco-editor/react": "^4.7.0",
Expand Down
8 changes: 8 additions & 0 deletions apps/web/yapi.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ environments:

prod:
url: https://yapi.run

test:
start: pnpm dev --port 3000
wait_on:
- http://localhost:3000/healthz
timeout: 60s
parallel: 16
all: true
Loading
Loading