bknd-testing
Use when writing tests for Bknd applications, setting up test infrastructure, creating unit/integration tests, or testing API endpoints. Covers in-memory database setup, test helpers, mocking, and test patterns.
What this skill does
# Testing Bknd Applications
Write and run tests for Bknd applications using Bun Test or Vitest with in-memory databases for isolation.
## Prerequisites
- Bknd project set up locally
- Test runner installed (Bun or Vitest)
- Understanding of async/await patterns
## When to Use UI Mode
- Manual integration testing via admin panel
- Verifying data after test runs
- Quick smoke testing
## When to Use Code Mode
- Automated unit tests
- Integration tests
- CI/CD pipelines
- Regression testing
## Test Runner Setup
### Bun (Recommended)
Bun has a built-in test runner:
```bash
# Run all tests
bun test
# Run specific file
bun test tests/posts.test.ts
# Watch mode
bun test --watch
```
### Vitest
```bash
# Install
bun add -D vitest
# Configure vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
},
});
# Run
npx vitest
```
## In-Memory Database Setup
Use in-memory SQLite for fast, isolated tests.
### Test Helper Module
Create `tests/helper.ts`:
```typescript
import { App, createApp as baseCreateApp } from "bknd";
import { em, entity, text, number, boolean } from "bknd";
import Database from "libsql";
// Schema for tests
export const testSchema = em({
posts: entity("posts", {
title: text().required(),
content: text(),
published: boolean(),
}),
comments: entity("comments", {
body: text().required(),
author: text(),
}),
}, (fn, s) => {
fn.relation(s.comments).manyToOne(s.posts);
});
// Create isolated test app with in-memory DB
export async function createTestApp(options?: {
seed?: (app: App) => Promise<void>;
}) {
const db = new Database(":memory:");
const app = new App({
connection: { database: db },
schema: testSchema,
});
await app.build();
if (options?.seed) {
await options.seed(app);
}
return {
app,
cleanup: () => {
db.close();
},
};
}
// Create test API client
export async function createTestClient(app: App) {
const baseUrl = "http://localhost:0"; // Placeholder
return {
data: app.modules.data,
auth: app.modules.auth,
};
}
```
### Bun-Specific Helper
For Bun's native SQLite:
```typescript
import { bunSqlite } from "bknd/adapter/bun";
import { Database } from "bun:sqlite";
export function createTestConnection() {
const db = new Database(":memory:");
return bunSqlite({ database: db });
}
```
## Unit Testing Patterns
### Testing Entity Operations
```typescript
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
import { createTestApp } from "./helper";
describe("Posts", () => {
let app: Awaited<ReturnType<typeof createTestApp>>;
beforeEach(async () => {
app = await createTestApp();
});
afterEach(() => {
app.cleanup();
});
test("creates a post", async () => {
const result = await app.app.em
.mutator("posts")
.insertOne({ title: "Test Post", content: "Hello" });
expect(result.id).toBeDefined();
expect(result.title).toBe("Test Post");
});
test("reads posts", async () => {
// Seed data
await app.app.em.mutator("posts").insertOne({ title: "Post 1" });
await app.app.em.mutator("posts").insertOne({ title: "Post 2" });
const posts = await app.app.em.repo("posts").findMany();
expect(posts).toHaveLength(2);
});
test("updates a post", async () => {
const created = await app.app.em
.mutator("posts")
.insertOne({ title: "Original" });
const updated = await app.app.em
.mutator("posts")
.updateOne(created.id, { title: "Updated" });
expect(updated.title).toBe("Updated");
});
test("deletes a post", async () => {
const created = await app.app.em
.mutator("posts")
.insertOne({ title: "To Delete" });
await app.app.em.mutator("posts").deleteOne(created.id);
const found = await app.app.em.repo("posts").findOne(created.id);
expect(found).toBeNull();
});
});
```
### Testing Relationships
```typescript
describe("Comments", () => {
let app: Awaited<ReturnType<typeof createTestApp>>;
beforeEach(async () => {
app = await createTestApp();
});
afterEach(() => app.cleanup());
test("creates comment with relation", async () => {
const post = await app.app.em
.mutator("posts")
.insertOne({ title: "Parent Post" });
const comment = await app.app.em
.mutator("comments")
.insertOne({
body: "Great post!",
posts_id: post.id,
});
expect(comment.posts_id).toBe(post.id);
});
test("loads comments with post", async () => {
const post = await app.app.em
.mutator("posts")
.insertOne({ title: "Post" });
await app.app.em.mutator("comments").insertOne({
body: "Comment 1",
posts_id: post.id,
});
const comments = await app.app.em.repo("comments").findMany({
with: { posts: true },
});
expect(comments[0].posts).toBeDefined();
expect(comments[0].posts.title).toBe("Post");
});
});
```
## Integration Testing
### HTTP API Testing
Test the full HTTP stack:
```typescript
import { describe, test, expect, beforeAll, afterAll } from "bun:test";
import { serve } from "bknd/adapter/bun";
describe("API Integration", () => {
let server: ReturnType<typeof Bun.serve>;
const port = 3999;
const baseUrl = `http://localhost:${port}`;
beforeAll(async () => {
server = Bun.serve({
port,
fetch: (await serve({
connection: { url: ":memory:" },
schema: testSchema,
})).fetch,
});
});
afterAll(() => {
server.stop();
});
test("GET /api/data/posts returns 200", async () => {
const res = await fetch(`${baseUrl}/api/data/posts`);
expect(res.status).toBe(200);
const data = await res.json();
expect(data).toEqual({ data: [] });
});
test("POST /api/data/posts creates record", async () => {
const res = await fetch(`${baseUrl}/api/data/posts`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ title: "API Test" }),
});
expect(res.status).toBe(201);
const { data } = await res.json();
expect(data.title).toBe("API Test");
});
});
```
### Testing with SDK Client
```typescript
import { Api } from "bknd/client";
describe("SDK Integration", () => {
let api: Api;
let server: ReturnType<typeof Bun.serve>;
beforeAll(async () => {
// Start test server
server = await startTestServer();
api = new Api({ host: "http://localhost:3999" });
});
afterAll(() => server.stop());
test("creates and reads via SDK", async () => {
const created = await api.data.createOne("posts", {
title: "SDK Test",
});
expect(created.ok).toBe(true);
const read = await api.data.readOne("posts", created.data.id);
expect(read.data.title).toBe("SDK Test");
});
});
```
## Testing Authentication
### Auth Flow Testing
```typescript
describe("Authentication", () => {
let app: Awaited<ReturnType<typeof createTestApp>>;
beforeEach(async () => {
app = await createTestApp({
auth: {
enabled: true,
strategies: {
password: {
hashing: "plain", // Only for tests!
},
},
},
});
});
afterEach(() => app.cleanup());
test("registers a user", async () => {
const auth = app.app.modules.auth;
const result = await auth.register({
email: "[email protected]",
password: "password123",
});
expect(result.user).toBeDefined();
expect(result.user.email).toBe("[email protected]");
});
test("login with correct password", async () => {
const auth = app.app.modules.auth;
// Register first
await auth.register({
email: "[email protected]",
password: "password123",
});
// Then login
const result = await auth.login({
email: "[email protected]",
password: "password123",
});
expect(result.token).toBeDefRelated 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.