testing-patterns_skill

This skill helps you apply testing patterns and principles to unit, integration, and mocking strategies, improving reliability and maintainability of test
  • TypeScript

5.7k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill vudovn/antigravity-kit --skill testing-patterns

  • SKILL.md3.4 KB

Overview

This skill describes practical testing patterns and principles for TypeScript projects, covering unit, integration, and end-to-end approaches. It focuses on reliable, maintainable test suites with concrete strategies for mocking, test organization, and test data management. The content emphasizes speed, isolation, and readable tests that serve as documentation.

How this skill works

The skill outlines the testing pyramid to guide test type distribution and applies the Arrange-Act-Assert pattern to structure cases. It explains selection criteria for unit, integration, and E2E tests and provides concrete mocking types (stub, spy, mock, fake) and when to use them. It also prescribes setup/teardown for integration tests, data generation strategies, and naming/grouping conventions to keep suites fast and deterministic.

When to use it

  • Write unit tests for pure functions, business logic, and edge cases to keep them fast and isolated.
  • Use integration tests for API endpoints, database queries, and service contracts that require multiple components.
  • Reserve E2E tests for critical user flows and cross-system behavior where user-facing correctness matters most.
  • Mock external APIs, network calls, time, or randomness during unit tests to remove flakiness.
  • Employ factories, fixtures, or builders when you need repeatable realistic test data across suites.

Best practices

  • Follow Arrange-Act-Assert and keep tests self-checking and repeatable with no manual steps.
  • Aim for fast tests (<100ms for unit) and independent cases with one clear assertion per test when practical.
  • Name tests descriptively using should/when or given-when-then patterns and group related cases with describe blocks.
  • Use setup/teardown hooks (beforeAll, beforeEach, afterEach, afterAll) for resource management and state reset.
  • Prefer behavior testing over implementation testing; replace duplicated setup with factories or helpers.

Example use cases

  • Unit test a business validation function with stubs for time and random inputs.
  • Integration test an API route against a temporary test database with beforeEach state reset.
  • E2E test a checkout flow to verify critical user journeys across frontend and backend.
  • Replace fragile external HTTP calls with fakes during unit testing and validate contract in integration tests.
  • Use builders to produce minimal, realistic domain objects for complex test scenarios.

FAQ

Follow the testing pyramid: many unit tests, some integration tests, and few E2E tests focused on critical flows.

When should I mock the database?

Mock the database for unit tests to keep them isolated; use a real or test database for integration tests to validate queries and transactions.

What if a test is flaky?

Investigate root cause: isolate external dependencies, add proper setup/teardown, replace unstable mocks with controlled fakes, or move the scenario to a more appropriate test type.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
testing-patterns skill by vudovn/antigravity-kit | VeilStrat