testing-patterns

Provides testing standards and patterns for TypeScript, Rust, Swift, and Go projects.

Updated Jan 1, 2026
One-click install
npx skills add https://github.com/sarkarshivaditya-lab/WellMate --skill testing-patterns-sarkarshivaditya-lab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/sarkarshivaditya-lab/WellMate/tree/main/.engineering-skills/0xMassi-claude-skills/testing-patterns
Command: npx skills add https://github.com/sarkarshivaditya-lab/WellMate --skill testing-patterns-sarkarshivaditya-lab

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, maintainable tests across polyglot codebases is hard because each language has different frameworks, conventions, and mocking strategies. This Skill codifies proven testing patterns for TypeScript (Vitest), Rust (cargo test), Swift (Swift Testing), and Go (go test) so tests follow real-world project conventions instead of ad-hoc guesses. ## Core Features & Use Cases - Per-language conventions: File naming, test structure, and run commands for Vitest, cargo test, Swift Testing, and go test. - Mock strategies: Dependency injection with vi.fn(), trait-based stubs in Rust, test accessors in Swift, and interface injection in Go. - Cross-language guidance: Testing pyramid ratios, coverage targets, property-based testing libraries, anti-patterns, and GitHub Actions CI snippets. - Use Case: When adding tests to a Rust workspace crate, apply the inline #[cfg(test)] mod tests pattern with tokio async tests and scripted mock providers instead of inventing a structure. ## Quick Start Write unit tests for my new TypeScript permission resolver following the Vitest patterns in this skill.

Frequently Asked Questions about testing-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure unit tests in Rust with cargo test?▼

Place inline #[cfg(test)] mod tests modules at the bottom of each source file and run them with cargo test --lib. For async code use #[tokio::test], and filter tests by name substring or skip slow ones with -- --skip flags.

What mocking approach should I use with Vitest in TypeScript?▼

Prefer vi.fn() with dependency injection through function parameters over vi.mock() module mocks. Use vi.spyOn for existing methods, vi.stubEnv for environment variables, and always restore fake timers in afterEach to prevent cross-test leaks.

Swift Testing vs XCTest: which should I use for iOS tests?▼

This skill uses the modern Swift Testing framework with @Test macros, @Suite structs, and #expect assertions rather than XCTest. Use @Suite(.serialized) for shared state and @MainActor for UI-bound ViewModel tests.

How do I run Go tests with race detection in CI?▼

Run go test -race -cover ./... in your GitHub Actions workflow to catch data races and measure coverage. Test files use the *_test.go naming convention in the same package as the code under test for internal access.

When should I use property-based testing instead of example tests?▼

Use property-based testing when a function has expressible invariants like round-trip, commutativity, or idempotency, especially for parsers, codecs, and serialization. Libraries include fast-check for TypeScript, proptest for Rust, and testing/quick for Go.

What code should not be tested according to these patterns?▼

Skip testing framework internals, third-party API responses, trivial getters and delegation wrappers, and generated code. Focus coverage on boundary logic, parsing, serialization, crypto, state machines, and error paths.