typescript-testing-backend

Write Jest unit tests with mocked Prisma and Supertest integration tests against isolated PostgreSQL.

15|3|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/LazyIsEfficient/agentic-os --skill typescript-testing-backend
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-testing-backend
Source: https://github.com/LazyIsEfficient/agentic-os/tree/main/.claude/skills/typescript-testing-backend
Command: npx skills add https://github.com/LazyIsEfficient/agentic-os --skill typescript-testing-backend

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

TypeScript backend testing often requires balancing unit tests with mocked Prisma and real database integration, coordinating test data, and keeping tests co-located with source code. This skill provides a structured approach to writing and reviewing Jest-based tests for services and controllers, plus integration tests against an isolated PostgreSQL instance.

Core Features & Use Cases

  • Unit testing of services and controllers with mocked Prisma
  • Integration testing against an isolated PostgreSQL database using Supertest patterns
  • Co-located tests structure with shared test utilities and seed data guidance

Quick Start

Run Jest unit tests for services and controllers locally and validate integration tests against a real isolated PostgreSQL database.

Frequently Asked Questions about typescript-testing-backend

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

FAQPage Schema
How do I set up Jest integration testing against a real PostgreSQL database?

Jest integration testing against a real PostgreSQL database uses Supertest for HTTP requests and TestDatabase isolation to ensure a clean state. This approach validates API endpoints with real database interactions instead of relying on mocks.

What is the best way to mock Prisma client in TypeScript unit tests?

Mocking Prisma client in TypeScript unit tests is handled by enforcing module-boundary mocking within Jest. This isolates services and controllers from database side effects, producing fast and deterministic unit test results without hitting a real database.

How should I structure co-located __tests__ folders for a TypeScript backend?

Co-located __tests__ folders structure places test files directly alongside source code in the same directory. This organization keeps Jest unit and integration tests near services and controllers, simplifying test discovery and maintenance.

Does this backend testing approach require a specific Jest version?

Yes, this backend testing approach requires Jest 29 configured with @swc/jest. This specific configuration is enforced to ensure fast TypeScript compilation and consistent test execution across unit and integration suites.

How do I use Supertest with a TestServer setup in Jest?

Using Supertest with a TestServer setup in Jest involves initializing an isolated HTTP server instance within the test file. Supertest then sends requests to this TestServer to validate controllers against real database endpoints.

When should I use seeded data in backend integration tests?

Seeded data in backend integration tests should be used when validating read operations or complex database relationships against an isolated PostgreSQL instance. The skill provides seed data guidance to ensure consistent integration test premises.