🎯

analyzing-test-coverage

🎯Skill

from saleor/configurator

VibeIndex|
What it does

Analyzes and generates comprehensive tests using Vitest and MSW, creating test builders, mocking repositories, and configuring integration tests.

analyzing-test-coverage

Installation

Install skill:
npx skills add https://github.com/saleor/configurator --skill analyzing-test-coverage
4
AddedJan 27, 2026

Skill Details

SKILL.md

"Creates and analyzes tests using Vitest and MSW patterns. Generates test builders, mocks repositories, and configures integration tests. Triggers on: write tests, test coverage, Vitest, MSW mock, vi.fn, vi.mock, unit test, integration test, test builder, mock setup, test failure."

Overview

# Testing Strategy Analyst

Purpose

Guide the creation of comprehensive tests following project patterns for unit tests, integration tests, and E2E tests using Vitest, MSW, and project-specific test helpers.

When to Use

  • Writing new tests
  • Analyzing test coverage gaps
  • Setting up mocks for testing
  • Organizing test files
  • Debugging test failures

Table of Contents

  • [Testing Stack](#testing-stack)
  • [Test Organization](#test-organization)
  • [Quick Pattern Reference](#quick-pattern-reference)
  • [Running Tests](#running-tests)
  • [Test Quality Checklist](#test-quality-checklist)
  • [Common Pitfalls](#common-pitfalls)
  • [References](#references)

Testing Stack

| Tool | Purpose |

|------|---------|

| Vitest | Test runner and assertion library |

| MSW | Mock Service Worker for network mocking |

| vi | Vitest mock utilities |

| test-helpers/ | Project-specific test utilities |

Test Organization

```

src/

β”œβ”€β”€ modules/

β”‚ └── category/

β”‚ β”œβ”€β”€ category-service.ts

β”‚ β”œβ”€β”€ category-service.test.ts # Unit tests

β”‚ β”œβ”€β”€ repository.ts

β”‚ β”œβ”€β”€ repository.test.ts # Repository tests

β”‚ └── category.integration.test.ts # Integration tests

β”œβ”€β”€ core/

β”‚ └── diff/

β”‚ └── comparators/

β”‚ β”œβ”€β”€ category-comparator.ts

β”‚ └── category-comparator.test.ts

β”œβ”€β”€ test-helpers/

β”‚ β”œβ”€β”€ config-file-builder.ts

β”‚ β”œβ”€β”€ graphql-mocks.ts

β”‚ β”œβ”€β”€ config-fixtures.ts

β”‚ └── cli-runner.ts

└── lib/

└── test-setup.ts # Global test setup

e2e/

└── ... # End-to-end tests

```

Quick Pattern Reference

Service Tests

See references/patterns.md for full examples. Key structure:

  • Declare dependencies at suite level
  • Reset mocks in beforeEach with vi.clearAllMocks()
  • Use describe blocks for method grouping
  • Follow Arrange-Act-Assert pattern

Repository Tests with MSW

See references/patterns.md for MSW setup. Key steps:

  1. Define handlers with graphql.query() / graphql.mutation()
  2. Setup server with beforeAll / afterAll
  3. Override handlers for specific test cases with server.use()

Test Data Builders

See references/test-builders.md for implementations. Pattern:

  • Create builder class with fluent interface
  • Validate with Zod schema in build()
  • Provide factory functions for convenience

Mock Functions

See references/patterns.md for examples. Common patterns:

  • vi.fn() for simple mocks
  • vi.mocked() for typed access
  • vi.mock() for module mocking

Running Tests

```bash

# Run all tests

pnpm test

# Run specific test file

pnpm test -- --filter=category-service

# Run tests matching pattern

pnpm test -- --grep="should create category"

# Watch mode

pnpm test -- --watch

# With coverage

pnpm test -- --coverage

```

See references/commands-reference.md for advanced options and coverage configuration.

Test Quality Checklist

For Every Test

  • [ ] Follows Arrange-Act-Assert pattern
  • [ ] Has descriptive test name
  • [ ] Tests one thing per test
  • [ ] Includes both positive and negative cases
  • [ ] Uses typed mocks (not any)
  • [ ] Cleans up after itself (beforeEach/afterEach)

For Test Suites

  • [ ] Covers all public methods
  • [ ] Covers error scenarios
  • [ ] Covers edge cases
  • [ ] Uses schema-validated test data
  • [ ] Has integration tests for complex flows

Validation Checkpoints

| Phase | Validate | Command |

|-------|----------|---------|

| Test written | File exists | Check *.test.ts created |

| Tests pass | All green | pnpm test |

| Coverage adequate | Key paths covered | pnpm test --coverage |

| Mocks typed | No any in mocks | npx tsc --noEmit |

Common Pitfalls

Not Resetting Mocks:

```typescript

beforeEach(() => {

vi.clearAllMocks(); // Always reset!

});

```

Testing Implementation Details:

```typescript

// BAD - tests internal structure

expect(service.internalMap.size).toBe(1);

// GOOD - tests behavior

expect(await service.findBySlug('test')).toBeDefined();

```

Flaky Async Tests:

```typescript

// BAD - race condition

const result = service.process();

expect(result).toBe(expected);

// GOOD - await properly

const result = await service.process();

expect(result).toBe(expected);

```

References

Skill Reference Files

  • references/patterns.md - Detailed test patterns with full code examples
  • references/test-builders.md - Builder pattern implementations
  • references/commands-reference.md - Complete command reference

Project Resources

  • {baseDir}/src/test-helpers/ - Test utilities
  • {baseDir}/vitest.config.ts - Test configuration
  • {baseDir}/docs/TESTING_PROTOCOLS.md - Testing protocols

External Documentation

  • Vitest docs: https://vitest.dev
  • MSW docs: https://mswjs.io

Related Skills

  • Complete entity workflow: See adding-entity-types for E2E implementation including tests
  • Zod test patterns: See designing-zod-schemas for schema validation tests
  • GraphQL mocking: See writing-graphql-operations for MSW handlers

Quick Reference Rule

For a condensed quick reference, see .claude/rules/testing-standards.md (automatically loaded when editing *.test.ts files).

More from this repository8

🎯
implementing-cli-patterns🎯Skill

Here's a concise, practical description for the "implementing-cli-patterns" skill: Implements consistent CLI user experiences with color-coded output, progress indicators, interactive prompts, and...

🎯
creating-changesets🎯Skill

Automates changeset creation for semantic versioning, determining version bump type and generating detailed release notes.

🎯
reviewing-typescript-code🎯Skill

Reviews TypeScript code for type safety, clean code principles, functional patterns, Zod validation, and error handling across various project scenarios.

🎯
designing-zod-schemas🎯Skill

Designs and validates Zod schemas with type inference, supporting complex validation patterns, branded types, and transformations.

🎯
understanding-saleor-domain🎯Skill

Explains Saleor e-commerce domain, revealing entity identification, deployment pipeline, and configuration management strategies for developers.

🎯
writing-graphql-operations🎯Skill

Generates type-safe GraphQL operations using gql.tada and urql, implementing a repository pattern for Saleor API interactions with robust error handling.

🎯
validating-pre-commit🎯Skill

Validates code quality by running linting, TypeScript compilation, tests, and CI checks before committing or pushing changes.

🎯
managing-github-ci🎯Skill

Configures and manages GitHub Actions workflows, automates releases via Changesets, validates PRs, and troubleshoots CI pipeline failures.