Get the FREE Ultimate OpenClaw Setup Guide →

ln-743-test-infrastructure

npx machina-cli add skill levnikolaevich/claude-code-skills/ln-743-test-infrastructure --openclaw
Files (1)
SKILL.md
6.5 KB

Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.

ln-743-test-infrastructure

Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-740-quality-setup

Sets up testing frameworks, coverage tools, and sample tests for projects.


Purpose & Scope

Does:

  • Detects project stack to choose appropriate test framework
  • Creates test configuration files
  • Sets up coverage reporting with thresholds
  • Creates sample tests demonstrating patterns
  • Verifies test suite runs successfully

Does NOT:

  • Configure linters (ln-741 does this)
  • Set up pre-commit hooks (ln-742 does this)
  • Write actual application tests (developers do this)

Supported Stacks

TechnologyTest FrameworkCoverage ToolConfig File
TypeScript/ReactVitestv8/Istanbulvitest.config.ts
.NETxUnitCoverlet*.Tests.csproj
Pythonpytestpytest-covpytest.ini or pyproject.toml

Phase 1: Check Existing Tests

Before creating test infrastructure, check what exists.

Files to Check:

StackTest Indicators
TypeScriptvitest.config.*, jest.config.*, *.test.ts, *.spec.ts
.NET*.Tests.csproj, *.IntegrationTests.csproj
Pythonpytest.ini, conftest.py, tests/, test_*.py

Decision Logic:

  1. If complete test setup exists: SKIP (inform user)
  2. If partial setup: ASK to extend or replace
  3. If no tests: CREATE from templates

Phase 2: Create Test Configuration

TypeScript/React (Vitest)

Create vitest.config.ts:

  • Use v8 coverage provider (faster than Istanbul)
  • Configure jsdom environment for React
  • Set coverage thresholds (80% minimum)
  • Create setup file for testing-library

Dependencies:

npm install -D vitest @vitest/coverage-v8 @testing-library/react @testing-library/jest-dom jsdom

.NET (xUnit)

Create test project:

dotnet new xunit -n {Project}.Tests
dotnet sln add tests/{Project}.Tests

Dependencies (in .csproj):

  • Microsoft.NET.Test.Sdk
  • xunit
  • xunit.runner.visualstudio
  • Moq
  • FluentAssertions
  • coverlet.collector

Python (pytest)

Add to pyproject.toml or create pytest.ini:

  • Configure test discovery paths
  • Set coverage thresholds (80% minimum)
  • Configure coverage reporting

Dependencies:

pip install pytest pytest-cov pytest-asyncio
# OR with uv:
uv add --dev pytest pytest-cov pytest-asyncio

Phase 3: Create Test Directory Structure

TypeScript

src/
├── components/
│   ├── Button.tsx
│   └── Button.test.tsx  # Co-located tests
├── test/
│   └── setup.ts         # Test setup file

.NET

tests/
├── {Project}.Tests/
│   ├── Controllers/
│   │   └── SampleControllerTests.cs
│   ├── Services/
│   └── {Project}.Tests.csproj
└── {Project}.IntegrationTests/  # Optional

Python

tests/
├── __init__.py
├── conftest.py          # Fixtures
├── unit/
│   └── test_sample.py
└── integration/         # Optional

Phase 4: Create Sample Tests

Create one sample test per stack demonstrating:

  • AAA pattern (Arrange-Act-Assert)
  • Test naming conventions
  • Basic assertions
  • Framework-specific patterns

TypeScript Sample Test

Shows:

  • render() from testing-library
  • screen queries
  • Jest-dom matchers

.NET Sample Test

Shows:

  • [Fact] attribute
  • Moq for mocking
  • FluentAssertions syntax

Python Sample Test

Shows:

  • pytest fixtures
  • assert statements
  • parametrized tests (optional)

Phase 5: Verify Test Run

After setup, verify tests work.

TypeScript:

npm test
npm run test:coverage

Expected: Sample test passes, coverage report generated

.NET:

dotnet test
dotnet test --collect:"XPlat Code Coverage"

Expected: Sample test passes, coverage collected

Python:

pytest
pytest --cov=src --cov-report=term-missing

Expected: Sample test passes, coverage report shown

On Failure: Check test configuration, dependencies, verify sample test syntax.


Coverage Requirements

MetricMinimumTarget
Lines70%80%
Branches70%80%
Functions70%80%
Statements70%80%

Configure CI to fail if coverage drops below thresholds.


Critical Rules

RULE 1: Coverage thresholds MUST be configured. No exceptions.

RULE 2: Sample tests MUST pass. Don't create broken examples.

RULE 3: Use AAA pattern (Arrange-Act-Assert) in all sample tests.

RULE 4: Co-locate unit tests with source (TypeScript) or use tests/ directory (.NET, Python).


Definition of Done

  • Test framework installed and configured
  • Coverage tool configured with 80% threshold
  • Test directory structure created
  • Sample test created and passing
  • npm test / dotnet test / pytest runs successfully
  • Coverage report generates
  • User informed of:
    • How to run tests
    • Where to add new tests
    • Coverage requirements

Reference Files

FilePurpose
vitest_template.tsVitest config template
vitest_setup_template.tsTest setup file
react_test_template.tsxReact component test
xunit_csproj_template.xml.NET test project
xunit_test_template.csxUnit test example
pytest_config_template.tomlpytest config
pytest_test_template.pypytest test example
testing_guide.mdTesting best practices

Error Handling

ErrorCauseResolution
Vitest not foundNot installednpm install -D vitest
jsdom errorsMissing dependencynpm install -D jsdom
xUnit discovery failsSDK version mismatchUpdate Microsoft.NET.Test.Sdk
pytest not foundNot in PATHpip install pytest
Coverage 0%Wrong source pathCheck coverage.include config

Version: 2.0.0 Last Updated: 2026-01-10

Source

git clone https://github.com/levnikolaevich/claude-code-skills/blob/master/ln-743-test-infrastructure/SKILL.mdView on GitHub

Overview

ln-743-test-infrastructure auto-detects your project stack (TypeScript/React, .NET, or Python), then creates test configuration files, coverage tooling, and sample tests. It validates that the test suite runs successfully and sets clear coverage thresholds.

How This Skill Works

It scans the repo to determine the stack and existing tests, then generates stack-specific setup files (vitest.config.ts for TS, a .NET test project with xUnit and Moq, or pytest.ini/pyproject.toml for Python). It wires coverage reporting with thresholds (e.g., 80%), adds sample tests demonstrating AAA patterns, and provides steps to verify the test run.

When to Use It

  • Starting a new repository and want ready-to-run testing across TS, .NET, or Python
  • Adding a formal test infra to an existing repo with minimal or no tests
  • Supporting a monorepo that contains multiple tech stacks and needs per-stack config
  • Enforcing a standard coverage threshold and sample tests before CI
  • When you want a quick bootstrap to verify test execution locally

Quick Start

  1. Step 1: Run the ln-743-test-infrastructure skill at the repo root
  2. Step 2: Review any ASK prompts, then proceed to generate stack-specific config
  3. Step 3: Run tests (npm test / dotnet test / pytest) and verify coverage output

Best Practices

  • Run the check phase first to detect existing tests and avoid overwriting
  • Keep stack-specific configurations isolated (Vitest, xUnit, pytest) to reduce complexity
  • Set coverage thresholds (80%) and rely on CI to enforce them
  • Include co-located sample tests to demonstrate AAA pattern
  • Document the created files and how to extend tests in the project README

Example Use Cases

  • A TS/React app gets vitest.config.ts and a sample Button.test.tsx
  • A .NET solution receives a new {Project}.Tests project with Controllers tests
  • A Python package adds pytest.ini and sample tests under tests/
  • A mono-repo with TS and Python stacks boots multi-stack test infra
  • An existing repo with partial tests prompts to extend or replace the setup

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers