<< All versions

Skill v1.0.0

currentAutomated scan100/100
adyba/pi-safe-workflow/testing-patterns
──Details
PublishedOctober 4, 2026 at 04:05 PM
Content Hashsha256:d77dbc1e056ecf68...
Git SHA
──Files
Files (1 file, 2.0 KB)
SKILL.md2.0 KBactive
SKILL.md · 96 lines · 2.0 KB

version: "1.0.0" name: testing-patterns description: > Testing patterns for unit, integration, and end-to-end tests. Use when writing tests, setting up test fixtures, or validating RLS enforcement. Routes to existing test conventions.


Testing Patterns Skill

Purpose

Guide consistent and effective testing. Routes to existing test patterns and provides evidence templates.

When This Skill Applies

  • Writing unit or integration tests
  • Setting up test fixtures with RLS
  • Running test suites
  • Packaging test evidence

Critical Rules

FORBIDDEN

typescript
// Direct Prisma calls bypass RLS
const user = await prisma.user.findUnique({ where: { user_id } });
// Shared test state causes flaky tests
let sharedUser: User;
beforeAll(() => { sharedUser = createUser(); });

CORRECT

typescript
// Use RLS context helpers
const user = await withSystemContext(prisma, "test", async (client) => {
return client.user.findUnique({ where: { user_id } });
});
// Isolated test state
beforeEach(() => {
const testUser = createTestUser();
});
// Unique identifiers
const userId = `user-${crypto.randomUUID()}`;

Test Commands

bash
{{TEST_UNIT_COMMAND}} # Unit tests
{{TEST_INTEGRATION_COMMAND}} # Integration tests
{{TEST_E2E_COMMAND}} # E2E tests (Playwright)
{{CI_VALIDATE_COMMAND}} # Full validation

Test Directory Structure

__tests__/
├── unit/ # Fast, isolated tests
├── integration/ # API and database tests
├── e2e/ # End-to-end tests
└── setup.ts # Global setup

Evidence Template

markdown
**Test Execution Evidence**
**Test Suite**: [unit/integration/e2e]
**Files Changed**: [list files]
**Test Results:**
-Total Tests: [X]
-Passed: [X]
-Failed: [0]
**Commands Run:**

{{TEST_UNIT_COMMAND}} --coverage

Reference

  • Jest Config: jest.config.js
  • RLS Context: lib/rls-context.ts
  • Pattern Library: patterns_library/testing/
All versions