skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
blogic-cz/blogic-marketplace91 installs

testing-patterns

This skill should be used when implementing or reviewing testing workflows in template-ts projects, especially for testing, Vitest, Playwright, integration test, and mocking scenarios.

How do I install this agent skill?

npx skills add https://github.com/blogic-cz/blogic-marketplace --skill testing-patterns
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    This skill provides safe and standard guidance for implementing unit, integration, and E2E tests in a TypeScript project using Vitest, TRPC, and Playwright. It follows best practices by using environment variables for test credentials and local in-memory databases for integration tests.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

  • Runlayerpass

    1 file scanned · No issues

What does this agent skill do?

Testing Patterns

Use this skill to choose the lightest effective test type and apply project-consistent patterns for Vitest unit tests, TRPC integration tests with PGlite, and Playwright E2E tests.

Test Hierarchy (prefer simpler first)

  1. Unit tests (preferred) - Cover pure functions, parsers, and Effect services.
  2. TRPC integration tests - Cover full TRPC + database behavior.
  3. E2E tests - Cover browser and full user flows.

When to Use Each

SituationTest TypeAction
Pure function, parser, utilUnitWrite immediately
Effect service with dependenciesUnit with mock layersWrite immediately
TRPC procedure (DB logic)TRPC integrationFollow decision process
User-facing flow, UI behaviorE2EFollow decision process

Test File Locations

Code LocationTest Location
packages/X/src/file.tspackages/X/src/__tests__/file.test.ts
apps/web-app/src/infrastructure/trpc/routers/X.tsapps/web-app/src/__tests__/X.test.ts
apps/web-app/src/routes/**apps/web-app/e2e/feature.e2e.ts

Decision Process (canonical)

Before writing any test, apply this sequence:

  1. Can this be unit tested? Write a unit test immediately.
  2. Does this require DB behavior (joins, constraints, TRPC + persistence)?
    • If the user explicitly requested an integration test, implement it directly.
    • Otherwise, ask a question like: "Would you like an integration test for this TRPC/database behavior?"
  3. Does this require browser/UI flow validation?
    • If the user explicitly requested E2E coverage, implement it directly.
    • Otherwise, ask a question like: "Would you like an E2E test here? It is the most expensive test type to maintain."

Never re-ask for a test type that the user already requested explicitly.

Unit Test Patterns

Use unit tests by default.

For concrete examples, see references/examples.md:

  • Basic Vitest
  • Effect tests with @effect/vitest and mock layers
  • Service-layer tests using real service logic with mocked boundaries

Clarify terminology: "service-layer tests using real service logic with mocked boundaries" means testing the real service implementation while replacing external boundaries (for example HTTP, DB, or filesystem clients) with mocks.


TRPC Integration Test Patterns

Follow the canonical decision process above for consent and escalation.

For concrete setup and seed-helper examples, see references/examples.md.

Use seed helpers from @project/db/testing to set up the minimum required state per case.


E2E Test Patterns

Follow the canonical decision process above for consent and escalation.

For concrete E2E and auth-helper examples, see references/examples.md.

Warn about maintenance cost only when E2E was not explicitly requested.


Commands

bun run test              # Run all unit + TRPC integration tests
bun run test:watch        # Watch mode
bun run test:coverage     # With coverage

# E2E scripts live in apps/web-app
(cd apps/web-app && bun run test:e2e)     # Run E2E tests
(cd apps/web-app && bun run test:e2e:ui)  # E2E with UI

# Run a specific test file (use a path that exists in the project)
bun run vitest run <path-to-test-file>

Avoid these command patterns:

# These DO NOT work:
bun run test packages/common/src/__tests__/file.test.ts  # script doesn't accept path
cd packages/common && bun run vitest run src/__tests__/file.test.ts  # wrong cwd

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/blogic-cz/blogic-marketplace/testing-patterns">View testing-patterns on skillZs</a>