testing-patterns

Write unit, integration, and E2E tests with Jest, Supertest, and Playwright.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/SleyiW/iWana-neXt --skill testing-patterns-sleyiw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/SleyiW/iWana-neXt/tree/main/.agents/skills/testing-patterns
Command: npx skills add https://github.com/SleyiW/iWana-neXt --skill testing-patterns-sleyiw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, maintainable tests across a NestJS backend, web frontend, and E2E flows is hard when each layer uses different tools and conventions. This Skill provides concrete testing patterns aligned with the project's real stack so tests validate behavior instead of implementation details. ## Core Features & Use Cases - Layered Test Pyramid: Covers unit tests with Jest, integration tests with Jest + Supertest for HTTP contracts, and E2E flows with Playwright. - Ready-to-Use Patterns: Includes data factories, service unit tests, Supertest endpoint tests, React Testing Library component tests, and Playwright login flows. - Project Conventions: Enforces coverage thresholds (85% lines/functions, 80% branches), multi-tenant integration test context, mocking rules, and anti-pattern avoidance. - Use Case: When fixing a bug in a NestJS endpoint, first reproduce the failure with a Supertest integration test including the tenant header, then apply the fix and confirm the test passes. ## Quick Start Write a Jest unit test and a Supertest integration test for the login endpoint following the project testing patterns.

Frequently Asked Questions about testing-patterns

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

FAQPage Schema
How do I write integration tests for NestJS with Supertest?

Create a NestJS TestingModule, get the HTTP server with app.getHttpServer(), and use Supertest's request() to send HTTP calls and assert on status and body. Include Authorization and X-Tenant-Slug headers when the endpoint requires tenant context.

How to write E2E tests with Playwright for login flows?

Use Playwright's test() with the page fixture: navigate with page.goto(), fill fields via getByLabel(), click with getByRole(), and assert visibility with expect(...).toBeVisible(). Keep E2E tests independent of unstable or random data.

What should I mock in Jest unit tests?

Mock external integrations only, never the logic under test. Prefer small, explicit test doubles, clean mocks between tests, and avoid turning a unit test into a simulation of the entire application.

Can I use React Native Testing Library in this project?

No. This project targets a web frontend, so use @testing-library/react for component tests. Examples based on @testing-library/react-native are explicitly listed as an anti-pattern for this repository.

What coverage thresholds does Jest enforce in this project?

The expected Jest configuration sets coverageThreshold with 85% for lines, functions, and statements, and 80% for branches. Tests should run with --coverage in CI, and these minimums apply to all core modules.

When should I not write automated tests for a task?

Skip this approach when the task is pure exploration without test needs, when it targets mobile or React Native, or when validation is exclusively manual. The patterns are designed for the Jest, Supertest, and Playwright stack only.