Generated banner for Code Testing Extensions
Generated logo for Code Testing Extensions

Code Testing Extensions

.NET (Microsoft)OfficialPublished by .NET (Microsoft)

  • Skill
  • Guidelines
  • Software development
  • MIT
  • Low risk

From the author

Provides file paths to language-specific extension files for the code-testing pipeline. Read this reference-only catalog for extension guidance files (e.g., dotnet.md for .NET, cpp.md for C++). Agents and skills read its bundled files directly; do not invoke this catalog through the model's skill tool.
— the description by .NET (Microsoft)

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Code Testing Extensions is a non-invocable reference library designed to support automated testing workflows. It provides a structured collection of documentation files covering various programming languages, including .NET, Python, TypeScript, Go, Java, and more. Each entry offers essential guidance on build and test commands, framework-specific patterns, mocking strategies, and common error resolution. Additionally, the catalog includes example files that demonstrate complete testing pipeline cycles, from research and planning to test generation and reporting.

What it does

  • Provides language-specific testing guidance for multiple programming environments.
  • Lists standard build and test commands for various testing frameworks.
  • Offers best practices for mocking, project layout, and framework detection.
  • Includes concrete examples of full testing pipeline workflows.
  • Serves as a centralized reference for agents to ensure consistent testing standards.

When to use it

  • When an agent needs to determine the correct testing commands for a specific language.
  • When implementing or debugging a testing pipeline for a new project.
  • When guidance on framework-specific mocking or test structure is required.
  • When looking for representative examples of a complete test generation cycle.

Advantages

  • Ensures consistency across different testing environments.
  • Reduces ambiguity by providing standardized commands and patterns.
  • Provides both high-level guidance and concrete implementation examples.
  • Supports a wide range of modern programming languages and frameworks.

Usage examples

“Read extensions/python.md to understand the preferred testing patterns for a pytest project.”
The agent retrieves the Python-specific guidance, identifying the correct test runner commands and mocking strategies to apply.
“Consult extensions/java-examples.md to see how to structure a JUnit 5 test suite.”
The agent reviews the provided example to replicate the established project structure and testing conventions for the Java codebase.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/dotnet/code-testing-extensions/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip code-testing-extensions.zip -d .agents/skills

Documentation by .NET (Microsoft)

Code Testing Extensions

This reference-only catalog lists bundled guidance for the code-testing pipeline. Read the matching file directly; do not invoke this catalog as a skill. Resource paths are relative to this catalog, not the project workspace.

Available Extension Files

FileLanguageContents
extensions/dotnet.md.NET (C#/F#/VB)Build commands, test commands, project reference validation, common CS error codes, MSTest template
extensions/python.mdPythonFramework-adaptive test commands (pytest, custom runners), project layout detection, mocking guidelines, common errors
extensions/typescript.mdTypeScript/JavaScriptBuild/test commands (Jest/Vitest/Mocha), framework detection, mocking, TS-specific considerations
extensions/powershell.mdPowerShellTest commands (Pester v5), module import patterns, discovery/run pitfalls, mocking, common errors
extensions/cpp.mdC++Testing internals with friend declarations
extensions/go.mdGogo test commands, table-driven tests, integration vs unit layout, mocking via interfaces, common errors
extensions/java.mdJavaMaven/Gradle commands, JUnit 4/5 and TestNG detection, Mockito, Spring Boot slices, common errors
extensions/rust.mdRustcargo test commands, unit vs integration vs doc tests, features, async test harnesses, common errors
extensions/ruby.mdRubyRSpec and Minitest commands, Bundler usage, Rails specifics, mocking patterns, common errors
extensions/swift.mdSwiftSPM and Xcode test commands, XCTest vs Swift Testing, @testable import, async/throws tests, common errors
extensions/kotlin.mdKotlinGradle commands, JUnit/Kotest detection, MockK, coroutines test, KMP and Android specifics, common errors
extensions/dotnet-examples.md.NET (C#/F#/VB)Concrete pipeline examples: sample research output, plan, generated tests, fix cycles, final report
extensions/python-examples.mdPythonConcrete pipeline examples (pytest): research, plan, generated test file, fix cycles, final report
extensions/typescript-examples.mdTypeScript/JavaScriptConcrete pipeline examples (Vitest, applicable to Jest): research, plan, generated test file, fix cycles, final report
extensions/go-examples.mdGoConcrete pipeline examples (standard testing): research, plan, table-driven test file, fix cycles, final report
extensions/java-examples.mdJavaConcrete pipeline examples (JUnit 5 + Mockito on Maven): research, plan, generated test file, fix cycles, final report

Usage

Read the appropriate base extension before writing test code. Load an <language>-examples.md file only when the repository has no representative tests and the base extension does not resolve the needed pattern. Do not load end-to-end examples for a focused request with established local conventions.

Files

extensions/typescript.md

TypeScript Extension

Language-specific guidance for TypeScript (and JavaScript) test generation.

Rule #1: Investigate the Repo First

Before writing any test or running any command, read:

  1. Existing tests — find *.test.ts / *.spec.ts files and copy their style (imports, describe/it vs test, assertion patterns, mock approach)

  2. package.json — scripts.test, devDependencies, type field

  3. Config files — tsconfig.json, jest.config.*, vitest.config.*, eslint.config.*

Use the repo's existing test runner and conventions — do not switch frameworks. If multiple runners are configured, follow whichever scripts.test invokes. Only introduce a framework if the repo has no tests at all.

Package Manager Detection

Detect the package manager from lockfiles and use it consistently for all commands:

IndicatorManagerRun scriptExecute binary
pnpm-lock.yamlpnpmpnpm testpnpm exec <tool>
yarn.lockYarnyarn testyarn <tool>
bun.lockb / bun.lockBunbun testbunx <tool>
package-lock.json or nonenpmnpm testnpx <tool>

Use <exec> below as shorthand for the detected exec command.

Build Commands

ScopeCommand
Type check<exec> tsc --noEmit or the repo's typecheck script
Build (if configured)The repo's build script

Many projects don't need an explicit build step — the test runner handles transpilation.

Test Commands

Detect the runner from devDependencies and scripts.test. Always prefer the repo's test script first.

RunnerRun onceFilter by fileFilter by name
Jest<exec> jest<exec> jest path/to/file<exec> jest -t "name"
Vitest<exec> vitest run<exec> vitest run path/to/file<exec> vitest run -t "name"
Mocha<exec> mocha(use config or positional args)<exec> mocha --grep "name"
  • Always use vitest run (not bare vitest) — bare vitest starts watch mode

  • Never use --watch — the agent must not start interactive/watch mode

  • For Jest: --bail to stop on first failure, --verbose for detail

  • Mocha --grep filters by test name, not file path

Lint Command

Use the repo's lint script first. Otherwise detect from devDependencies and config:

  • eslint.config.* or .eslintrc.* → <exec> eslint --fix path/to/file.ts

  • prettier → <exec> prettier --write path/to/file.ts

  • biome.json → <exec> biome check --write path/to/file.ts

Project Layout and Imports

LayoutImport Style
Colocated (src/module.test.ts)import { X } from './module'
__tests__/ dirimport { X } from '../module'
Top-level tests/import { X } from '../src/module'
  • Match existing test imports — copy path style from neighboring tests

  • If tsconfig.json has paths aliases (e.g., @/), use them in tests too

  • For monorepos: import from the package name, not relative cross-package paths

  • For monorepo workspaces (Nx, Turborepo, Lerna): run tests via the workspace tool (nx test <project>, turbo test), not from a random package directory

Test File Naming

  • Match existing convention — check for .test.ts vs .spec.ts

  • Jest/Vitest default: *.test.ts, *.spec.ts, or files inside __tests__/

  • Place test files to mirror the existing project pattern

Parameterized Test Display Names

Apply Report-safe test names and result validation. For Jest it.each/test.each, interpolate only a safe label ($Name for object rows), or use a short behavior label with %# for the case index. Do not use %p, %s, or $Input/$Expected to render arbitrary data in the title. Harmless numeric placeholders such as %i remain fine.

For a word counter whose contract treats form-feed as whitespace, keep the real U+000C input but give the case a safe name:

it.each([
  { Name: "form-feed separator", Input: "one\ftwo", Expected: 2 },
  { Name: "space separator", Input: "one two", Expected: 2 },
])("countWords: $Name", ({ Input, Expected }) => {
  expect(countWords(Input)).toBe(Expected);
});

The escape in Input becomes an actual control character at runtime; the title does not contain it. Reuse the configured reporter and validate its exported artifact when required/configured; do not install jest-junit just for this check.

Common Errors

ErrorFix
Cannot find module 'X'Check existing imports for correct paths; verify tsconfig.json paths; check moduleNameMapper (Jest) or resolve.alias (Vitest)
TS2305: has no exported memberVerify the exact export name from the source file
TS2345: type not assignableMatch the expected type; use type assertion only for mock objects
SyntaxError: Unexpected token / Jest encountered an unexpected tokenVerify TS transform config (ts-jest, @swc/jest, or Vitest handles natively)
ReferenceError: describe is not definedVitest: import from vitest or set globals: true in config; Jest: ensure tests run under Jest not bare node
Cannot use import statement outside a module / ERR_REQUIRE_ESMESM/CJS mismatch — align runner config with the project's module system (see ESM section); do not blindly set "type": "module"
ReferenceError: document is not definedSet test environment: testEnvironment: 'jsdom' (Jest) or environment: 'jsdom' (Vitest)
jest.mock() ... out-of-scope variablesKeep jest.mock() at top level; don't reference variables declared after the mock call (Jest hoists mocks)
Cannot find module '@/...'Mirror the project's alias config in the test runner's module resolution
Warning: not wrapped in act(...)Await async UI updates using the repo's existing pattern (waitFor, act)

ESM vs CommonJS

Check these signals to determine the project's module system:

  • "type": "module" in package.json → ESM

  • "module": "ESNext" or "NodeNext" in tsconfig.json → ESM output (but not sufficient alone)

  • .mjs/.mts extensions → ESM files

If the test runner fails with ESM errors, align the runner's config with the project's module system. Do not change package.json type field — align the test runner to match whatever the project uses:

  • Jest: --experimental-vm-modules + ts-jest with useESM: true, or @swc/jest

  • Vitest: handles ESM natively

  • Mocha: --loader ts-node/esm

Mocking Rules

  • Prefer dependency injection over module mocking

  • Use typed mocks: jest.Mocked<T>, vi.mocked(obj), or Partial<T> with as T

  • Jest: jest.mock() is hoisted — keep at top level, don't close over local variables

  • Vitest: vi.mock() follows the same hoisting rules

  • If a test needs more than 3–4 mocks, flag it as a design smell

  • Mock reset: rely on clearMocks/restoreMocks config if present; otherwise reset in beforeEach

Framework-Specific Notes

  • React/Preact: use @testing-library/react, wrap with necessary providers (router, query client, theme) matching existing test setup

  • Express/Koa: use supertest for HTTP testing if the repo already uses it

  • NestJS: build testing module with Test.createTestingModule — don't instantiate controllers directly

Dependency Installation (Last Resort)

Only install packages after investigation confirms they are missing. Use the detected package manager:

<manager> add --save-dev jest ts-jest @types/jest
<manager> add --save-dev vitest

Never install test infrastructure that conflicts with what the repo already uses.

Skip Coverage Tools

Do not configure or run coverage tools (istanbul, c8, vitest --coverage). Coverage is measured separately by the evaluation harness.

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter, Needs Python

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
.NET (Microsoft)
Publisher
.NET (Microsoft) (Official)
Source
dotnet/skills · plugins/dotnet-test/skills/code-testing-extensions · commit 96c3d68
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by .NET (Microsoft).

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download code-testing-extensions.zip