Jest Testing Patterns
ChrisWiles/claude-code-showcase
Jest patterns for React Native style tests: TDD discipline, mock factory functions, module and GraphQL hook mocking, custom render helpers and anti-patterns to avoid.
Enforces red-green-refactor for new RTK output filters in Rust, using real captured fixtures, snapshot tests with insta and token-savings assertions.
$ npx skills add rtk-ai/rtk --skill tdd-rust -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install rtk-ai/rtk tdd-rust --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/tdd-rust .claude/skills/tdd-rust && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .claude/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rustType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add rtk-ai/rtk --skill tdd-rust -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install rtk-ai/rtk tdd-rust --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.claude/skills/tdd-rust .agents/skills/tdd-rust && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .agents/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add rtk-ai/rtk --skill tdd-rust -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install rtk-ai/rtk tdd-rust --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.claude/skills/tdd-rust .cursor/skills/tdd-rust && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .cursor/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/rtk-ai/rtk.git --path .claude/skills/tdd-rust--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add rtk-ai/rtk --skill tdd-rust -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install rtk-ai/rtk tdd-rust --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.claude/skills/tdd-rust .gemini/skills/tdd-rust && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .gemini/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install rtk-ai/rtk tdd-rustInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add rtk-ai/rtk --skill tdd-rust -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .github/skills && cp -r skills-src/.claude/skills/tdd-rust .github/skills/tdd-rust && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .github/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add rtk-ai/rtk --skill tdd-rust -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install rtk-ai/rtk tdd-rust --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.claude/skills/tdd-rust .opencode/skills/tdd-rust && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "tdd-rust" agent skill from https://github.com/rtk-ai/rtk/tree/develop/.claude/skills/tdd-rust into .opencode/skills/tdd-rust/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "tdd-rust", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
tdd-rustEnforces red-green-refactor for new RTK output filters in Rust, using real captured fixtures, snapshot tests with insta and token-savings assertions.
The skill runs a strict TDD loop for RTK filter development. It starts from a real fixture, never synthetic data, captured from the actual command into tests/fixtures as a raw text file. Then it writes a failing test, implements the minimum code to pass, accepts a snapshot, wires the filter into main.rs and runs the quality gate of cargo fmt, cargo clippy and cargo test, with zero clippy warnings allowed.
Test patterns include arrange-act-assert, ANSI stripping, fallback behavior on unexpected input, and token savings at several sizes, where a large fixture must still reach at least 60% savings. The done checklist asks for a real fixture, a filter function returning a Result, an accepted insta snapshot, a savings test, and no panic on empty or malformed input.
6 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit e0b2e85. It shows what the files ask for, not the result of running them.
Pre-approves these tools, so the agent can use them without asking each time:
ReadWriteEditBashFrom allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
cargogitghFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use git and gh, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
RTK Filter TDD in Rust loads about 1.9k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 153 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check noted patterns worth knowing about, such as sudo or a known installer.
allowed-tools: Read, Write, Edit, BashAutomated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from rtk-ai/rtk at commit e0b2e85, republished under its Apache-2.0 licence (© rtk-ai). 153 words, ~1,885 tokens.
.claude/skills/tdd-rust/SKILL.md (or your agent's skills folder).Enforce Red-Green-Refactor for all RTK filter development.
1. RED — Write failing test with real fixture
2. GREEN — Implement minimum code to pass
3. REFACTOR — Clean up, verify still passing
4. SAVINGS — Verify ≥60% token reduction
5. SNAPSHOT — Lock output format with instaNever write synthetic test data. Capture real command output:
# Capture real output from the actual command
git log -20 > tests/fixtures/git_log_raw.txt
cargo test 2>&1 > tests/fixtures/cargo_test_raw.txt
cargo clippy 2>&1 > tests/fixtures/cargo_clippy_raw.txt
gh pr view 42 > tests/fixtures/gh_pr_view_raw.txt
# For commands with ANSI codes — capture as-is
script -q /dev/null cargo test 2>&1 > tests/fixtures/cargo_test_ansi_raw.txtFixture naming: tests/fixtures/<command>_raw.txt
#[cfg(test)]
mod tests {
use super::*;
use insta::assert_snapshot;
fn count_tokens(s: &str) -> usize {
s.split_whitespace().count()
}
// Test 1: Output format (snapshot)
#[test]
fn test_filter_output_format() {
let input = include_str!("../tests/fixtures/mycmd_raw.txt");
let output = filter_mycmd(input).expect("filter should not fail");
assert_snapshot!(output);
}
// Test 2: Token savings ≥60%
#[test]
fn test_token_savings() {
let input = include_str!("../tests/fixtures/mycmd_raw.txt");
let output = filter_mycmd(input).expect("filter should not fail");
let input_tokens = count_tokens(input);
let output_tokens = count_tokens(&output);
let savings = 100.0 * (1.0 - output_tokens as f64 / input_tokens as f64);
assert!(
savings >= 60.0,
"Expected ≥60% token savings, got {:.1}% ({} → {} tokens)",
savings, input_tokens, output_tokens
);
}
// Test 3: Edge cases
#[test]
fn test_empty_input() {
let result = filter_mycmd("");
assert!(result.is_ok());
// Empty input = empty output OR passthrough, never panic
}
#[test]
fn test_malformed_input() {
let result = filter_mycmd("not valid command output\nrandom text\n");
// Must not panic — either filter best-effort or return input unchanged
assert!(result.is_ok());
}
}Run: cargo test → should fail (function doesn't exist yet).
// src/mycmd_cmd.rs
use anyhow::{Context, Result};
use regex::Regex;
use std::sync::LazyLock;
static ERROR_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^error").unwrap());
pub fn filter_mycmd(input: &str) -> Result<String> {
if input.is_empty() {
return Ok(String::new());
}
let filtered: Vec<&str> = input.lines()
.filter(|line| ERROR_RE.is_match(line))
.collect();
Ok(filtered.join("\n"))
}Run: cargo test → green.
# First run creates the snapshot
cargo test test_filter_output_format
# Review what was captured
cargo insta review
# Press 'a' to accept
# Snapshot saved to src/snapshots/mycmd_cmd__tests__test_filter_output_format.snap// src/main.rs
mod mycmd_cmd;
#[derive(Subcommand)]
pub enum Commands {
// ... existing commands ...
Mycmd(MycmdArgs),
}
// In match:
Commands::Mycmd(args) => mycmd_cmd::run(args),// src/mycmd_cmd.rs — add run() function
pub fn run(args: MycmdArgs) -> Result<()> {
let output = execute_command("mycmd", &args.to_vec())
.context("Failed to execute mycmd")?;
let filtered = filter_mycmd(&output.stdout)
.unwrap_or_else(|e| {
eprintln!("rtk: filter warning: {}", e);
output.stdout.clone()
});
tracking::record("mycmd", &output.stdout, &filtered)?;
print!("{}", filtered);
if !output.status.success() {
std::process::exit(output.status.code().unwrap_or(1));
}
Ok(())
}cargo fmt --all && cargo clippy --all-targets && cargo testAll 3 must pass. Zero clippy warnings.
#[test]
fn test_filters_only_errors() {
// Arrange
let input = "info: starting build\nerror[E0001]: undefined\nwarning: unused\n";
// Act
let output = filter_mycmd(input).expect("should succeed");
// Assert
assert!(output.contains("error[E0001]"), "Should keep error lines");
assert!(!output.contains("info:"), "Should drop info lines");
assert!(!output.contains("warning:"), "Should drop warning lines");
}#[test]
fn test_strips_ansi_codes() {
let input = "\x1b[32mSuccess\x1b[0m\n\x1b[31merror: failed\x1b[0m\n";
let output = filter_mycmd(input).expect("should succeed");
assert!(!output.contains("\x1b["), "ANSI codes should be stripped");
assert!(output.contains("error: failed"), "Content should be preserved");
}#[test]
fn test_filter_handles_unexpected_format() {
// Give it something completely unexpected
let input = "completely unexpected\x00binary\xff data";
// Should not panic — returns Ok() with either empty or passthrough
let result = filter_mycmd(input);
assert!(result.is_ok(), "Filter must not panic on unexpected input");
}#[test]
fn test_savings_large_output() {
// 1000-line fixture → must still hit ≥60%
let large_input: String = (0..1000)
.map(|i| format!("info: processing item {}\n", i))
.collect();
let output = filter_mycmd(&large_input).expect("should succeed");
let savings = 100.0 * (1.0 - count_tokens(&output) as f64 / count_tokens(&large_input) as f64);
assert!(savings >= 60.0, "Large output savings: {:.1}%", savings);
}Checklist before moving on:
tests/fixtures/<cmd>_raw.txt — real command outputfilter_<cmd>() function returns Result<String>cargo insta reviewrun() function with fallback patternmain.rs Commands enumcargo fmt --all && cargo clippy --all-targets && cargo test — all green// ❌ Synthetic fixture data
let input = "fake error: something went wrong"; // Not real cargo output
// ❌ Missing savings test
#[test]
fn test_filter() {
let output = filter_mycmd(input);
assert!(!output.is_empty()); // No savings verification
}
// ❌ unwrap() in production code
let filtered = filter_mycmd(input).unwrap(); // Panic in prod
// ❌ Regex inside the filter function
fn filter_mycmd(input: &str) -> Result<String> {
let re = Regex::new(r"^error").unwrap(); // Recompiles every call
...
}© rtk-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .claude/skills/tdd-rust of rtk-ai/rtk.
Open the folder on GitHubat commit e0b2e85
RTK Filter TDD in Rust next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| RTK Filter TDD in Rust this skillrtk-ai/rtk | 83k | — | ~1.9k | Automated safety check: Notes | Apache-2.0 | |
| Jest Testing PatternsChrisWiles/claude-code-showcase | 6.1k | 7 repos | ~1.5k | Automated safety check: Pass | None | |
| Testingstatic-web-server/static-web-server | 2.4k | — | ~1.5k | Automated safety check: Pass | Apache-2.0 | |
| Rust Testingkurealnum/dotfiles | 290 | 6 repos | ~2.9k | Automated safety check: Pass | None | |
| Agent-Core Python TestingopenJiuwen-ai/agent-core | 441 | — | ~2.3k | Automated safety check: Pass | Apache-2.0 | |
| Godot Testing Patternsthedivergentai/GD-Agentic-Skills | 803 | — | ~2.9k | Automated safety check: Pass | LGPL-3.0 |
ChrisWiles/claude-code-showcase
Jest patterns for React Native style tests: TDD discipline, mock factory functions, module and GraphQL hook mocking, custom render helpers and anti-patterns to avoid.
static-web-server/static-web-server
Write or review tests for the Static Web Server (SWS) project — unit tests, integration tests, test fixtures, and mocking strategies
kurealnum/dotfiles
Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage.
openJiuwen-ai/agent-core
Pytest patterns for the agent-core codebase: a red-green-refactor workflow, conftest fixtures, custom marks, monkeypatch and patch mocking, and async tests.
thedivergentai/GD-Agentic-Skills
Expert testing decision trees for GdUnit4: unit vs scene vs CI gates, headless runners, snapshots, and mock networks.
modu-ai/moai-adk
Drives test-first development through the RED, GREEN, REFACTOR cycle, with a config switch that selects between TDD and a DDD workflow for existing code.
rtk-ai/rtk
Enforces red-green-refactor for Rust work, with idiomatic test patterns, a naming convention and a pre-commit gate of cargo fmt, clippy and test.
rtk-ai/rtk
Describes seven Rust design patterns for the RTK CLI filter modules, with when to use each, RTK examples, and notes on when a pattern is overkill.
rtk-ai/rtk
Reviews RTK's Rust code for over-engineering and verbose patterns, applying idioms like iterator chains and early returns while protecting a specific list of constraints from being simplified away.
rtk-ai/rtk
Audits open GitHub issues, categorizes them, flags duplicates and linked PRs in three phases, with optional deep analysis and comments posted only after validation.
rtk-ai/rtk
Audits a repository's open pull requests, deep-reviews chosen ones and drafts review comments that are only posted after you approve them.
rtk-ai/rtk
Runs issue triage and PR triage in parallel, then cross-analyzes the results to flag duplicate coverage, security gaps, P0 issues with no PR, and PR conflicts.
Works with
Categories
Enforces red-green-refactor for new RTK output filters in Rust, using real captured fixtures, snapshot tests with insta and token-savings assertions. The skill runs a strict TDD loop for RTK filter development. It starts from a real fixture, never synthetic data, captured from the actual command into tests/fixtures as a raw text file.
RTK Filter TDD in Rust fits situations like: adding a new output filter to RTK; writing snapshot tests for a filter with insta; verifying that a filter meets the token savings target.
Run `npx skills add rtk-ai/rtk --skill tdd-rust -a claude-code`. Or copy the skill folder (.claude/skills/tdd-rust in rtk-ai/rtk) into .claude/skills/tdd-rust in your project. Claude Code loads it when a task matches its description.
Run `npx skills add rtk-ai/rtk --skill tdd-rust -a codex`. Or copy the skill folder (.claude/skills/tdd-rust in rtk-ai/rtk) into .agents/skills/tdd-rust in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rtk-ai/rtk --skill tdd-rust -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tdd-rust, .gemini/skills/tdd-rust, .github/skills/tdd-rust and .opencode/skills/tdd-rust in your project.
Going by SKILL.md and its folder, RTK Filter TDD in Rust needs the command-line tools its instructions call (cargo, git and gh). Our summary lists: Rust with cargo and clippy; The insta snapshot tool; A checkout of the RTK repository. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash.
SKILL.md contains no URLs. Its commands use git and gh, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.
RTK Filter TDD in Rust is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with RTK Filter TDD in Rust: Jest Testing Patterns (ChrisWiles/claude-code-showcase, 6.1k stars), Testing (static-web-server/static-web-server, 2.4k stars), Rust Testing (kurealnum/dotfiles, 290 stars) and Agent-Core Python Testing (openJiuwen-ai/agent-core, 441 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
rtk-ai (a GitHub organization) maintains it in rtk-ai/rtk, which has 82,568 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 7, 2026.
Source: rtk-ai/rtk on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.