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.
Write and run automated tests with Jest and Testing Library in the browser.
$ npx skills add live-codes/livecodes --skill testing -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install live-codes/livecodes testing --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/live-codes/livecodes.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/livecodes/testing .claude/skills/testing && 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 "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .claude/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testingType 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 live-codes/livecodes --skill testing -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install live-codes/livecodes testing --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/live-codes/livecodes.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/livecodes/testing .agents/skills/testing && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .agents/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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 live-codes/livecodes --skill testing -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install live-codes/livecodes testing --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/live-codes/livecodes.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/livecodes/testing .cursor/skills/testing && 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 "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .cursor/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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/live-codes/livecodes.git --path .agents/skills/livecodes/testing--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 live-codes/livecodes --skill testing -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install live-codes/livecodes testing --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/live-codes/livecodes.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/livecodes/testing .gemini/skills/testing && 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 "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .gemini/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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 live-codes/livecodes testingInstalls 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 live-codes/livecodes --skill testing -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/live-codes/livecodes.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/livecodes/testing .github/skills/testing && 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 "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .github/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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 live-codes/livecodes --skill testing -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install live-codes/livecodes testing --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/live-codes/livecodes.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/livecodes/testing .opencode/skills/testing && 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 "testing" agent skill from https://github.com/live-codes/livecodes/tree/develop/.agents/skills/livecodes/testing into .opencode/skills/testing/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "testing", 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.
testingWrite and run automated tests with Jest and Testing Library in the browser.
Testing is an agent skill from live-codes/livecodes. Write and run automated tests with Jest and Testing Library in the browser. Import code from script editor, use watch mode, and run tests programmatically. Load this skill when writing tests for playground code or running tests via SDK.
Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Testing & QA, covering Unit testing. It works with Testing Library and Jest. The repository describes itself as: A Code Playground That Just Works! The licence is MIT.
Read from SKILL.md and the folder at commit 5754e89. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
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.
Testing loads about 1.9k tokens when it runs. Until then it costs about 61 tokens; SKILL.md has 250 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 found no risky patterns in SKILL.md.
Automated 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 live-codes/livecodes at commit 5754e89, republished under its MIT licence (© live-codes). 250 words, ~1,896 tokens.
.claude/skills/testing/SKILL.md (or your agent's skills folder).LiveCodes includes Jest and Testing Library for automated testing in the browser. Tests run against the result page in real-time.
import { createPlayground } from 'livecodes';
// Project with tests
createPlayground('#container', {
template: 'jest', // Jest starter template
params: { tests: 'open' }, // Show tests panel
});
// Custom test configuration
createPlayground('#container', {
config: {
activeEditor: 'script',
script: {
language: 'javascript',
content: `
export function add(a, b) {
return a + b;
}
export function greet(name) {
return 'Hello, ' + name;
}
`,
},
tests: {
language: 'javascript',
content: `
import { add, greet } from './script';
describe('add', () => {
test('adds numbers', () => {
expect(add(1, 2)).toBe(3);
});
test('handles negatives', () => {
expect(add(-1, -2)).toBe(-3);
});
});
describe('greet', () => {
test('greets by name', () => {
expect(greet('World')).toBe('Hello, World');
});
});
`,
},
},
params: { tests: 'open' },
});// Script editor (script.js)
export default function greet(name) {
return 'Hello, ' + name;
}
export const add = (a, b) => a + b;
// Also available in global scope
window.multiply = (a, b) => a * b;// Tests editor
import greet, { add } from './script'; // Relative import, no extension
describe('imports', () => {
test('greet', () => {
expect(greet('World')).toBe('Hello, World');
});
test('add', () => {
expect(add(1, 2)).toBe(3);
});
});
describe('globals', () => {
test('multiply', () => {
expect(window.multiply(2, 3)).toBe(6);
});
});// React Testing Library
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';
test('button click', async () => {
render(<MyComponent />);
await userEvent.click(screen.getByText('Click me'));
expect(screen.getByText('Clicked')).toBeInTheDocument();
});
// DOM Testing Library
import { getByText, waitFor } from '@testing-library/dom';
test('element appears', async () => {
document.body.innerHTML = '<div id="root"></div>';
// ... render something
await waitFor(() => {
expect(getByText(document.body, 'Loaded')).toBeTruthy();
});
});const playground = await createPlayground('#container', {
config: {
/* ... */
},
});
// Run tests and get results
const { results } = await playground.runTests();
results.forEach((result) => {
console.log(result.status); // 'pass', 'fail', or 'skip'
console.log(result.testPath); // ['describe', 'it']
console.log(result.duration); // milliseconds
console.log(result.errors); // string[] of error messages
});
// Watch for test results
playground.watch('tests', ({ results, error }) => {
if (error) {
console.error('Test error:', error);
return;
}
const passed = results.filter((r) => r.status === 'pass');
console.log(`${passed.length} tests passed`);
});// Jest globals available without import
describe('my tests', () => {
test('passes', () => {
expect(1 + 1).toBe(2);
});
test('asynchronous', async () => {
const result = await someAsyncFunction();
expect(result).toBe('expected');
});
test.skip('skipped', () => {
// Not run
});
test.only('run only this', () => {
// Only this test runs
});
});
// Lifecycle hooks
beforeAll(() => {
/* runs once before all tests */
});
afterAll(() => {
/* runs once after all tests */
});
beforeEach(() => {
/* runs before each test */
});
afterEach(() => {
/* runs after each test */
});
// Mocks
jest.fn();
jest.mocked(obj);
jest.spyOn(obj, 'method');import { assert } from 'chai';
describe('with Chai', () => {
test('assertions', () => {
assert.equal(1 + 1, 2);
assert.isArray([1, 2, 3]);
assert.include([1, 2, 3], 2);
});
});In the standalone app or visible tests panel:
Wrong:
// Script editor has syntax error
export function add(a, b) {
return a + // Syntax error - missing operand
}
// Tests editor - tests never run because script failed
import { add } from './script';
test('add', () => expect(add(1, 2)).toBe(3));Understanding:
// Tests run against the result page
// Script errors prevent the page from loading
// Always ensure script compiles before testing
// Check the console for script errors
// Fix script errors before writing testsTests are added to the result page. Script errors (import errors, syntax errors) prevent the result page from loading, which prevents tests from running.
Source: docs/docs/features/tests.mdx — Example section
Wrong:
import { add } from 'script'; // Missing ./
import { add } from './script.js'; // Has extensionCorrect:
import { add } from './script'; // Relative import, no extensionWhen importing from the script editor in tests, use relative imports without file extensions.
Source: docs/docs/features/tests.mdx — Importing Code section
| Feature | Support |
|---|---|
describe, test, it | Full support |
xtest, xit, fit | Skip/only tests |
xdescribe, fdescribe | Skip/only suites |
beforeAll, afterAll | Lifecycle hooks |
beforeEach, afterEach | Lifecycle hooks |
expect | Full matchers |
jest.fn(), jest.mocked() | Function mocks |
jest.spyOn() | Spy on methods |
jest.replaceProperty() | Property replacement |
| Library | Import |
|---|---|
| DOM Testing Library | import { getByText, waitFor } from '@testing-library/dom' |
| React Testing Library | import { render, screen } from '@testing-library/react' |
| jest-dom | import '@testing-library/jest-dom' |
| user-event | import userEvent from '@testing-library/user-event' |
| Chai | import { assert } from 'chai' |
Tests run in the browser using Jest. Libraries are automatically available — no import maps needed for testing libraries.
© live-codes, MIT. 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 .agents/skills/livecodes/testing of live-codes/livecodes.
Open the folder on GitHubat commit 5754e89
Testing 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 |
|---|---|---|---|---|---|---|
| Testing this skilllive-codes/livecodes | 1.5k | — | ~1.9k | Automated safety check: Pass | MIT | |
| Jest Testing PatternsChrisWiles/claude-code-showcase | 6.1k | 7 repos | ~1.5k | Automated safety check: Pass | None | |
| Write Testsgrafana/synthetic-monitoring-app | 171 | — | ~1.2k | Automated safety check: Pass | AGPL-3.0 | |
| Playwright Testingchongdashu/vibejam-starter-pack | 149 | — | ~2.1k | Automated safety check: Pass | None | |
| Unit TestsKhan/wonder-blocks | 163 | — | ~4.2k | Automated safety check: Pass | MIT | |
| React Testinggetsentry/sentry | 45k | — | ~2.2k | Automated safety check: Pass | Custom licence |
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.
grafana/synthetic-monitoring-app
Write Jest integration and unit tests for the Grafana Synthetic Monitoring app using React Testing Library, MSW, and src/test helpers.
chongdashu/vibejam-starter-pack
Plan, implement, and debug frontend tests: unit/integration/E2E/visual/a11y.
Khan/wonder-blocks
Jest + React Testing Library best practices for Wonder Blocks unit tests.
getsentry/sentry
Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library.
redis/RedisInsight
Unit/integration testing standards for RedisInsight using Jest and Testing Library: test structure, the renderComponent helper, faker for test data, mocking patterns, and waitFor instead of fixed…
live-codes/livecodes
Work with 90+ supported languages, compilers, CSS processors, and WASM-compiled languages for markup, style, and script editors.
live-codes/livecodes
Configure playground behavior through Config object, query parameters, EmbedOptions, editor settings, processors, external resources, and custom settings.
live-codes/livecodes
Configure how the playground is displayed: full, focus, simple, lite, editor, codeblock, and result modes.
live-codes/livecodes
Use SDK with React, Vue, Svelte, Solid, Preact, and Web Components.
live-codes/livecodes
Quick start for standalone app at livecodes.io, embedding playgrounds with CDN or npm, and self-hosting basics.
live-codes/livecodes
Use the "Preview in LiveCodes" GitHub Action to generate preview playground links for pull request code changes.
Works with
Categories
Write and run automated tests with Jest and Testing Library in the browser. Testing is an agent skill from live-codes/livecodes. Write and run automated tests with Jest and Testing Library in the browser.
Testing fits situations like: tasks that involve Unit testing.
Run `npx skills add live-codes/livecodes --skill testing -a claude-code`. Or copy the skill folder (.agents/skills/livecodes/testing in live-codes/livecodes) into .claude/skills/testing in your project. Claude Code loads it when a task matches its description.
Run `npx skills add live-codes/livecodes --skill testing -a codex`. Or copy the skill folder (.agents/skills/livecodes/testing in live-codes/livecodes) into .agents/skills/testing 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 live-codes/livecodes --skill testing -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/testing, .gemini/skills/testing, .github/skills/testing and .opencode/skills/testing in your project.
SKILL.md names no scripts, command-line tools or credentials: Testing is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Testing is published under the MIT 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.6k 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 Testing: Jest Testing Patterns (ChrisWiles/claude-code-showcase, 6.1k stars), Write Tests (grafana/synthetic-monitoring-app, 171 stars), Playwright Testing (chongdashu/vibejam-starter-pack, 149 stars) and Unit Tests (Khan/wonder-blocks, 163 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
live-codes (a GitHub organization) maintains it in live-codes/livecodes, which has 1,512 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on October 6, 2026.
Source: live-codes/livecodes on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.