backend-testing
Toolkit for backend API testing with proper test frameworks (vitest/jest, go test, pytest, cargo test). Supports verifying API endpoints, database state changes, error handling, and collecting test evidence. curl/httpie for testing is PROHIBITED - use proper test frameworks only. [MANDATORY] Before saying "implementation complete", you MUST use this skill to run tests and verify functionality. Completion reports without verification are PROHIBITED.
What this skill does
# Backend API Testing
To test backend APIs, use **proper test frameworks** for your language. Manual testing with curl/httpie is strictly prohibited.
**CRITICAL: Test File Placement**
- **ALWAYS** place test files in the project's standard test directory (`tests/`, `__tests__/`, `*_test.go`, etc.)
- **NEVER** place test scripts in `.artifacts/` - that's for evidence only (test output logs, coverage reports)
- Test files should be permanent project assets, not disposable artifacts
## Decision Tree: Framework Selection by Language
```
Project language → Which framework?
│
├─ Node.js / TypeScript
│ ├─ Vitest (preferred) + supertest
│ └─ Jest + supertest (if project already uses Jest)
│
├─ Go
│ └─ go test + net/http/httptest (stdlib)
│
├─ Python
│ ├─ pytest + httpx (preferred for async)
│ └─ pytest + requests (sync only)
│
└─ Rust
└─ cargo test + actix-web::test / axum::test / reqwest
```
## Test Framework Selection Table
| Language | Framework | HTTP Client | DB Access |
|----------|-----------|-------------|-----------|
| Node.js/TS | vitest or jest | supertest | prisma / drizzle / knex |
| Go | go test | net/http/httptest | database/sql / sqlx / gorm |
| Python | pytest | httpx / TestClient | sqlalchemy / asyncpg |
| Rust | cargo test | reqwest / framework test utils | sqlx / diesel |
## Example Tests
### Node.js (Vitest + supertest)
```typescript
// tests/api/users.test.ts
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import request from 'supertest';
import { app } from '../../src/app';
import { db } from '../../src/db';
describe('POST /api/users', () => {
beforeEach(async () => {
await db.execute('DELETE FROM users WHERE email = ?', ['[email protected]']);
});
afterEach(async () => {
await db.execute('DELETE FROM users WHERE email = ?', ['[email protected]']);
});
it('should create a user and return 201', async () => {
// Act
const res = await request(app)
.post('/api/users')
.send({ email: '[email protected]', name: 'Test User' })
.expect(201);
// Assert response body
expect(res.body).toMatchObject({
email: '[email protected]',
name: 'Test User',
});
expect(res.body.id).toBeDefined();
// Assert DB state changed
const rows = await db.query('SELECT * FROM users WHERE email = ?', ['[email protected]']);
expect(rows).toHaveLength(1);
expect(rows[0].name).toBe('Test User');
});
it('should return 400 for invalid email', async () => {
const res = await request(app)
.post('/api/users')
.send({ email: 'not-an-email', name: 'Test User' })
.expect(400);
expect(res.body.error).toContain('email');
// Assert DB was NOT modified
const rows = await db.query('SELECT * FROM users WHERE email = ?', ['not-an-email']);
expect(rows).toHaveLength(0);
});
it('should return 409 for duplicate email', async () => {
// Setup: create first user
await request(app)
.post('/api/users')
.send({ email: '[email protected]', name: 'First User' })
.expect(201);
// Act: attempt duplicate
const res = await request(app)
.post('/api/users')
.send({ email: '[email protected]', name: 'Duplicate User' })
.expect(409);
expect(res.body.error).toContain('already exists');
});
});
```
### Go (go test + httptest)
```go
// handlers/users_test.go
package handlers_test
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"myapp/handlers"
"myapp/db"
)
func TestCreateUser(t *testing.T) {
testDB := db.SetupTestDB(t)
defer testDB.Cleanup()
handler := handlers.NewUserHandler(testDB)
t.Run("creates user and returns 201", func(t *testing.T) {
body, _ := json.Marshal(map[string]string{
"email": "[email protected]",
"name": "Test User",
})
req := httptest.NewRequest(http.MethodPost, "/api/users", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()
handler.CreateUser(rec, req)
// Assert status code
assert.Equal(t, http.StatusCreated, rec.Code)
// Assert response body
var resp map[string]interface{}
err := json.Unmarshal(rec.Body.Bytes(), &resp)
require.NoError(t, err)
assert.Equal(t, "[email protected]", resp["email"])
// Assert DB state
user, err := testDB.GetUserByEmail("[email protected]")
require.NoError(t, err)
assert.Equal(t, "Test User", user.Name)
})
t.Run("returns 400 for invalid email", func(t *testing.T) {
body, _ := json.Marshal(map[string]string{
"email": "not-an-email",
"name": "Test User",
})
req := httptest.NewRequest(http.MethodPost, "/api/users", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()
handler.CreateUser(rec, req)
assert.Equal(t, http.StatusBadRequest, rec.Code)
})
}
```
### Python (pytest + httpx)
```python
# tests/test_users.py
import pytest
from httpx import AsyncClient, ASGITransport
from app.main import app
from app.db import get_session
@pytest.fixture
async def client():
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as ac:
yield ac
@pytest.fixture(autouse=True)
async def cleanup_db():
yield
async with get_session() as session:
await session.execute("DELETE FROM users WHERE email = '[email protected]'")
await session.commit()
@pytest.mark.asyncio
async def test_create_user_returns_201(client: AsyncClient):
# Act
response = await client.post("/api/users", json={
"email": "[email protected]",
"name": "Test User",
})
# Assert status code
assert response.status_code == 201
# Assert response body
data = response.json()
assert data["email"] == "[email protected]"
assert data["name"] == "Test User"
assert "id" in data
# Assert DB state changed
async with get_session() as session:
result = await session.execute(
"SELECT * FROM users WHERE email = '[email protected]'"
)
rows = result.fetchall()
assert len(rows) == 1
assert rows[0].name == "Test User"
@pytest.mark.asyncio
async def test_create_user_invalid_email_returns_400(client: AsyncClient):
response = await client.post("/api/users", json={
"email": "not-an-email",
"name": "Test User",
})
assert response.status_code == 400
assert "email" in response.json()["detail"]
```
### Rust (cargo test)
```rust
// tests/api/users.rs
use actix_web::test;
use actix_web::web::Data;
use myapp::{create_app, db::TestDb};
#[actix_web::test]
async fn test_create_user_returns_201() {
let test_db = TestDb::new().await;
let app = test::init_service(create_app(Data::new(test_db.pool.clone()))).await;
let req = test::TestRequest::post()
.uri("/api/users")
.set_json(serde_json::json!({
"email": "[email protected]",
"name": "Test User"
}))
.to_request();
let resp = test::call_service(&app, req).await;
// Assert status code
assert_eq!(resp.status(), 201);
// Assert response body
let body: serde_json::Value = test::read_body_json(resp).await;
assert_eq!(body["email"], "[email protected]");
assert_eq!(body["name"], "Test User");
// Assert DB state
let row = sqlx::query!("SELECT name FROM users WHERE email = $1", "[email protected]")
.fetch_one(&test_db.pool)
.await
.unwrap();
assert_eq!(row.name, "Test User");
test_db.cleanup().await;
}
#[actix_web::test]
async fn tesRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.