test-isolation_skill

This skill helps you enforce test isolation by guiding you to create independent tests, avoid shared state, and run reliably.
  • TypeScript

6

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 yanko-belov/code-craft --skill test-isolation

  • SKILL.md5.3 KB

Overview

This skill enforces test isolation for TypeScript test suites where shared state or test-order dependencies exist. It helps developers detect and eliminate coupling between tests so suites are reliable, parallelizable, and easy to debug. Follow its guidance when tests fail intermittently, rely on side effects, or require a specific execution order.

How this skill works

It inspects test code patterns that introduce shared mutable state (variables declared outside tests, beforeAll-created data, or tests that read state set by other tests). It recommends concrete isolation techniques: fresh instances per test, transactional rollbacks, in-memory stores, and factory functions to create test data. It also provides trigger points and remediation steps to refactor dependent tests into independent ones.

When to use it

  • When tests share mutable variables or rely on data created by other tests
  • When tests fail when run individually or in a different order
  • When the suite cannot run in parallel or flakes on CI
  • When beforeAll creates data consumed by multiple tests
  • During code reviews to catch test dependency smells

Best practices

  • Give each test its own setup and cleanup; use beforeEach instead of beforeAll for mutable state
  • Use transactional fixtures or rollback patterns for DB-backed tests
  • Prefer in-memory repositories or mocks that start fresh per test
  • Use factory functions to create deterministic test data with overrides
  • Avoid top-level mutable variables that tests mutate

Example use cases

  • Refactoring a test suite where one test creates a resource used by many others
  • Converting slow shared DB setup to per-test transactions that rollback
  • Detecting and removing flaky tests that pass when run together but fail alone
  • Preparing tests to run in parallel on CI by eliminating global state
  • Reviewing legacy specs that rely on execution order or implicit side effects

FAQ

Reusing data introduces implicit dependencies that cause intermittent failures and make debugging slower; small setup cost is preferable to flaky suites.

Is beforeAll always bad?

Not always—use beforeAll for read-only, immutable fixtures. Avoid it when it creates or mutates state consumed by multiple tests.

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