medcore-route-test

Generate deterministic Vitest unit tests for MedCore Express route handlers.

2|3|Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Globussoft-Technologies/medcore --skill medcore-route-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: medcore-route-test
Source: https://github.com/Globussoft-Technologies/medcore/tree/main/.claude/skills/medcore-route-test
Command: npx skills add https://github.com/Globussoft-Technologies/medcore --skill medcore-route-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It eliminates missing or fragile unit test coverage for MedCore Express route handlers by giving you a deterministic Vitest scaffold that pins RBAC behavior, Zod validation failures, and side effects without requiring a real database.

Core Features & Use Cases

  • Route surface discovery: Extracts every HTTP method/path registration, auth/RBAC middleware ordering, Zod schemas, Prisma calls, state-machine guards, and audit-log writes from apps/api/src/routes/<x>.ts.
  • Mock-safe unit tier: Generates unit tests that use hoisted Prisma mocks (no Postgres) and validates response shapes and error status codes.
  • Behavior-driven coverage strategy: Plans test clusters for unauthenticated, forbidden roles, validation rejections, happy paths, idempotency/fraud guards (where applicable), and audit-log assertions.

Quick Start

Use the medcore-route-test skill to scaffold apps/api/src/routes/<x>.test.ts by asking it to “write a unit test for /api/v1/<resource> route <x>”, optionally specifying which endpoints to cover.

Frequently Asked Questions about medcore-route-test

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

FAQPage Schema
How do I write Vitest unit tests for Express route handlers without a database?

To generate Vitest unit tests for Express routes, scaffold a test file that uses hoisted Prisma mocks to avoid real database calls, then assert response shapes, RBAC permissions, Zod validation rejections, and audit-log side effects deterministically.

How does mock-based RBAC testing work for API route handlers?

Mock-based RBAC testing extracts auth middleware ordering from your Express route file and uses hoisted mocks to simulate various user roles, allowing assertions for forbidden and unauthenticated response states without a real database connection.

Can I test Zod validation rejections and audit-log side effects in unit tests?

Yes, you can test Zod validation rejections and audit-log side effects by extracting route schemas and Prisma calls, then using hoisted mocks to verify invalid payloads trigger correct error status codes and audit writes execute as expected.

What's the best way to cover state-machine and fraud guards in API route unit tests?

The best way to cover state-machine and fraud guards is to extract these guards from your route file and generate behavior-driven test clusters validating idempotency and fraud prevention logic using deterministic mocked Prisma and auth middleware responses.

Do I need a real Postgres database to run Vitest unit tests for MedCore API routes?

No, you do not need a real Postgres database because the unit tests use hoisted Prisma mocks to simulate database interactions, ensuring tests remain deterministic by validating route handler logic and response shapes without actual DB calls.

Why are my Express route unit tests failing when Prisma mocks are not hoisted?

Express route unit tests fail without hoisted Prisma mocks because mock instances are unavailable during module initialization, preventing the test suite from intercepting database calls and validating state-machine guards or audit-log side effects correctly.