tests

Test Bun.serve HTTP servers with isolated ports, tokens, and database cleanup.

Updated Apr 16, 2025
One-click install
npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill tests-teexiii
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tests
Source: https://github.com/teexiii/boilerplate-rest-bun-for-noob/tree/main/.agent/skills/tests
Command: npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill tests-teexiii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill documents reliable integration testing patterns for Bun-based HTTP servers to validate full endpoint flows, authorization rules, error responses, and database interactions across test files.

Core Features & Use Cases

  • Isolated server setup using Bun.serve with a unique port per test file to avoid port collisions.
  • Test data and identity patterns including unique email generation, multiple user roles (owner, member, outsider), token generation, and role seeding via upsert.
  • HTTP response and authorization assertions, error case checks, nested describe organization for related flows, and ordered cleanup to respect foreign key constraints.
  • Use Case: validate user registration, authenticated resource creation, authorization denial, password reset flows, and end-to-end cleanup in a repeatable CI-friendly way.

Quick Start

Start an isolated Bun.serve test server on a unique port, seed roles and test users, generate access tokens, and run the integration tests against your API endpoints.

Frequently Asked Questions about tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up integration testing for a Bun.serve HTTP server?

Integration testing for a Bun.serve HTTP server involves starting an isolated server instance on a unique port per test file to avoid collisions, seeding database roles and users, and executing endpoint assertions followed by ordered teardown.

What is the best way to test token-based authorization in Bun API endpoints?

Testing token-based authorization in Bun APIs requires seeding specific user roles via database upsert, generating access tokens for those identities, and making authenticated HTTP requests to verify endpoint access control and authorization denial behaviors.

How do you prevent port collisions when running multiple Bun API integration tests?

Preventing port collisions in Bun API integration tests requires assigning a unique port to each Bun.serve test server instance, ensuring isolated server startup across parallel test files without network conflicts.

Can I test database interactions and Prisma teardown workflows in Bun integration tests?

Yes, you can test database interactions in Bun integration tests by seeding initial data, validating endpoint payload responses, and executing ordered database cleanup workflows to respect foreign key constraints during teardown.

How do I validate error responses and HTTP status codes in a Bun API test?

Validating error responses in a Bun API test involves sending invalid or unauthorized HTTP requests to your server endpoints and asserting the returned HTTP status codes and error payload structures match expected behaviors.