accelint-ts-testing_skill

This skill guides Vitest testing in TypeScript projects with AAA pattern, parameterized tests, async patterns, and property-based testing for robust coverage.
  • TypeScript

6

GitHub Stars

3

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 gohypergiant/agent-skills --skill accelint-ts-testing

  • AGENTS.md10.5 KB
  • README.md2.1 KB
  • SKILL.md15.7 KB

Overview

This skill provides comprehensive Vitest testing guidance tailored for TypeScript projects. It focuses on writing clear, fast, and reliable tests using AAA, parameterized tests, async/await patterns, and property-based testing with fast-check. The guidance prioritizes maintainability, correctness, and measurable improvements to test suites and reviews.

How this skill works

The skill inspects test files and project configuration to locate common anti-patterns and opportunities for stronger tests. It recommends config-level fixes (global mock cleanup), file-level organization, assertion improvements, test-double selection, async patterns, and where to apply fast-check properties like roundtrip and idempotence. When invoked for audits, it produces structured findings and actionable fixes using a standard report template.

When to use it

  • Writing new tests in *.test.ts with Vitest (use AAA, it.each, strict assertions)
  • Reviewing or auditing test code for anti-patterns (loose assertions, over-mocking, deep describe nesting)
  • Optimizing slow test suites or configuring global mock cleanup in vitest.config.ts
  • Implementing property-based tests with fast-check for encode/decode, validators, and idempotence checks
  • Converting duplicated tests into parameterized cases or simplifying complex setup

Best practices

  • Set clearMocks/resetMocks/restoreMocks in vitest.config.ts to avoid cross-test leaks
  • Prefer testing observable behavior over implementation details; avoid counting internal calls
  • Use strict assertions (deep equality, specific value checks) instead of toBeTruthy/toBeDefined
  • Mock only external dependencies; prefer fakes > stubs > spies > mocks for stability
  • Limit describe nesting to two levels and use descriptive test names for context
  • Use fast-check to assert strong properties: roundtrip(encode/decode), idempotence(normalize)

Example use cases

  • Convert several similar test cases into a single it.each parameterized test
  • Audit a repository to add global mock cleanup and identify flaky tests caused by shared state
  • Replace toBeTruthy assertions with precise shape or value checks to catch regressions
  • Add property-based tests for an encode/decode pair to catch edge-case inputs
  • Speed up suite by replacing real DB calls with in-memory fakes and mocking timers

FAQ

Use fast-check for functions with invariants, pure transforms, encode/decode pairs, sorting, or validators where broad input coverage finds edge cases that example tests miss.

How strict should assertions be?

Prefer exact value or deep-equality assertions that reflect the intended contract. Avoid loose truths like toBeTruthy unless the sole requirement is truthiness.

Where does global mock cleanup belong?

In vitest.config.ts via clearMocks/resetMocks/restoreMocks to eliminate mock leakage across test files; use setup files for shared helpers and matchers.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational