Agent skill

Write Unit Tests

by razorpay in razorpay/blade

This rule helps in writing and running unit tests for components of blade design system

MITAuto-check passedTesting & QA

Install Write Unit Tests

skills CLI
$ npx skills add razorpay/blade --skill write-unit-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install razorpay/blade write-unit-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/razorpay/blade.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/write-unit-tests .claude/skills/write-unit-tests && rm -rf skills-src

Use ~/.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/

Facts

Skill name
write-unit-tests
GitHub stars
656
Token cost
~1.2k tokens
SKILL.md length
385 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
MIT

At a glance

This rule helps in writing and running unit tests for components of blade design system

  • Tasks that involve Unit testing
  • SKILL.md covers Test File Structure, Testing Patterns, Element Selection Best Practices and Code Style in Tests, plus 5 more sections
  • Calls yarn
  • Tasks that involve Design systems

What it does

Write Unit Tests is an agent skill from razorpay/blade. This rule helps in writing and running unit tests for components of blade design system

Its SKILL.md is about 1.2k 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 and Design systems. The repository describes itself as: Design System that powers Razorpay. The licence is MIT.

When your agent uses it

  • Tasks that involve Unit testing
  • Tasks that involve Design systems

Example prompts

  • “/write-unit-tests”

What it can do on your machine

Read from SKILL.md and the folder at commit e65bdec. It shows what the files ask for, not the result of running them.

  • Tool permissions

    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.

  • Runs code

    Shell commands in SKILL.md call:

    • yarn

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use yarn, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Write Unit Tests loads about 1.2k tokens when it runs. Until then it costs about 26 tokens; SKILL.md has 385 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~26
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

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.

Safety

Auto-check passed

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.

SKILL.md

The full file from razorpay/blade at commit e65bdec, republished under its MIT licence (© razorpay). 385 words, ~1,234 tokens.

Download SKILL.mdSave it as .claude/skills/write-unit-tests/SKILL.md (or your agent's skills folder).
name
write-unit-tests
description
This rule helps in writing and running unit tests for components of blade design system

You work in a design system team of Razorpay and you're good at writing unit tests. You make sure to cover all important scenarios in tests while also ensuring that you don't write too many unnecessary tests.

  • You refer to existing tests for formats and inspirations. Refer to atleast 2 similar complexity components tests
  • You refer to story docs of that component for references on realisitic examples to test
  • When component is interactive, you test its core functionality
  • Before writing tests, you discuss which tests you're planning to write and only write tests post confirmation
  • You don't write ComponentName.native.test.tsx tests since that is not maintained anymore
  • Whenever you're unsure about some practice, just ask for confirmation

Blade Component Testing Guidelines

Test File Structure

  • Create tests in a __tests__ directory within the component folder
  • Use .web.test.tsx for web-specific tests and .ssr.test.tsx for server-side rendering tests
  • Follow the naming pattern: ComponentName.web.test.tsx and ComponentName.ssr.test.tsx

Testing Patterns

  • Always start by examining existing test patterns (e.g., Box component tests) to understand established conventions
  • Use renderWithTheme for web tests and renderWithSSR for SSR tests
  • Include assertAccessible test to ensure components meet accessibility standards
  • Import testing utilities from ~utils/testing/
Testing Utilities and Imports
typescript
import renderWithTheme from '~utils/testing/renderWithTheme.web';
import renderWithSSR from '~utils/testing/renderWithSSR';
import assertAccessible from '~utils/testing/assertAccessible.web';

Element Selection Best Practices

  • Always prefer getByRole over anything else wherever possible
  • Use testID props for precise element targeting in other cases where getByRole is not possible

Code Style in Tests

  • Keep test cases focused and well-named with clear descriptions
  • Avoid writing tests that can get flaky
  • Prefer toMatchSnapshot over toMatchInlineSnapshot especially in complex snapshots
  • Avoid unnecessary repeatitive tests. Keep tests concise
Show full SKILL.md (145 more words)Show less

Component Testing Patterns

  • Test different orientations, alignments, and layout configurations
  • For focussed testing of particular style, use getComputedStyle instead of adding snapshot for whole code
  • Include tests for conditional behavior that change the DOM structure heavily

Types of Tests

Styling/Layout Testing
  • When testing computed styles, use specific pixel values that match design tokens
  • Comment the expected values with their token references (e.g., // spacing.2 = 4px)
  • Test both presence and absence of styling conditions
Functional / Logic Testing
  • Use this pattern for triggering any events

    jsx
    import userEvents from '@testing-library/user-event';
    
    const user = userEvents.setup();
    // ...render example
    
    // click / other events
    await user.click(getByRole('button', { name: 'Toggle Show' }));
  • Test the core Logic

  • If there is any logic that is too complex or too flaky for unit tests, ignore it and suggest user to write integration test instead

Import Organization

typescript
// Component imports
import { ComponentName, SubComponent } from '../index';
// Testing utilities
import renderWithTheme from '~utils/testing/renderWithTheme.web';
import assertAccessible from '~utils/testing/assertAccessible.web';
// Blade components used in tests
import { Icon, Avatar, Badge, Amount } from '~components/...';

Test Structure Template

typescript
describe('<ComponentName />', () => {
  it('should render simple ComponentName', () => {
    // Basic rendering test with snapshot
  });

  it('should render ComponentName with different complex configurations', () => {
    // Test various prop combinations
  });

  // Test for any hacky implementations that we've added while writing code that are likely break or not intuitive
  it('should test for any hacky implementations', () => {
    // Test conditional behavior with actual assertions
  });

  // test for import styling scenario
  it('should render the important style', () => {
    // Test for 2 most important styles using getComputedStyle
  });

  // test for core functionality (ignore if component is non-interactive)
  it('should render ComponentName with different complex configurations', () => {
    // Test various prop combinations
  });

  it('should accept testID', () => {
    // Test testID prop support
  });

  it('should not have accessibility violations', async () => {
    // accessibility violation test
    await assertAccessible(container);
  });
});

Running the test

Run test using following command from packages/blade directory

sh
yarn test:react ComponentName

© razorpay, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/write-unit-tests of razorpay/blade.

Open the folder on GitHubat commit e65bdec

Compare with similar skills

Write Unit Tests 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.

Write Unit Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Write Unit Tests this skillrazorpay/blade656—~1.2kAutomated safety check: PassMIT
Testingradix-ng/primitives274—~3.3kAutomated safety check: PassMIT
Cometchat Android V6 Testingcometchat/cometchat-skills130—~1.7kAutomated safety check: PassMIT
Docs LookupProgrammerAnthony/Expert-Coding-Harness235—~640Automated safety check: PassMIT
TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph11211 repos~2.4kAutomated safety check: PassNone
Testing OpenLogi UIAprilNEA/OpenLogi23k—~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • Testing

    radix-ng/primitives

    Test Radix NG primitives across every layer and pick the RIGHT one for a change: Vitest unit (zoneless), jest-axe a11y, Playwright browser regression (apps/visual-regression), SSR…

    274 GitHub stars~3.3k tokensUpdated 9 days ago
    Testing & QAAuto-check passed
  • Cometchat Android V6 Testing

    cometchat/cometchat-skills

    Test an Android app that integrates the CometChat v6 UI Kit — make the SDK mockable behind a repository, unit-test the init/login gate and credential hygiene, write instrumented/Compose UI tests for…

    130 GitHub stars~1.7k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Docs Lookup

    ProgrammerAnthony/Expert-Coding-Harness

    通过 Context7 MCP 获取库和框架的实时最新文档,而非依赖训练数据,防止 API 幻觉。适用于查询任何库或框架的用法、配置、示例代码。触发词:怎么用、怎么配置、API参考、文档、示例代码、用法、接口、库文档、框架文档、documentation、docs、how to use、API…

    235 GitHub stars~640 tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed
  • TDD Workflow

    hellangleZ/burn-in-cceverywhere-ralph

    A skill your agent uses when writing new features, fixing bugs, or refactoring code.

    112 GitHub starsUsed in 11 repos~2.4k tokens
    Testing & QAAuto-check passed
  • Testing OpenLogi UI

    AprilNEA/OpenLogi

    Verifies OpenLogi's native GPUI interface with focused tests, the component gallery and a mock agent, choosing the evidence that fits each change.

    23k GitHub stars~1.1k tokensUpdated 4 days ago
    Testing & QAAuto-check passed
  • Go Testing

    cxuu/golang-skills

    A skill your agent uses when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff.

    170 GitHub starsUsed in 1 repo~1.3k tokens
    Testing & QAAuto-check passed

More from razorpay/blade

All 16 skills in this repo
  • Review PR

    razorpay/blade

    Review blade PRs by fetching diff, checking CI status, and getting Storybook URL.

    656 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Migrate To Rn

    razorpay/blade

    Add React Native support (.native.tsx files) to Blade components that currently only have web implementations.

    656 GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Migrate To Svelte

    razorpay/blade

    Orchestrate parallel migration of Blade React components to Svelte 5.

    656 GitHub stars~4.7k tokensUpdated today
    Auto-check passed
  • UI Code Guidelines

    razorpay/blade

    Important guidelines for writing frontend UI code. An agent skill from razorpay/blade.

    656 GitHub stars~866 tokensUpdated today
    Auto-check passed
  • Heal PR

    razorpay/blade

    Heal a Blade PR by fixing CI failures, missing changesets, and sanity issues.

    656 GitHub stars~414 tokensUpdated today
    Auto-check passed
  • Resolve Comments

    razorpay/blade

    Resolve PR review comments by pushing code fixes or replying with explanations.

    656 GitHub stars~647 tokensUpdated today
    Auto-check: warnings

Categories

Questions about Write Unit Tests

What does Write Unit Tests do?

This rule helps in writing and running unit tests for components of blade design system. Write Unit Tests is an agent skill from razorpay/blade.

When should I use Write Unit Tests?

Write Unit Tests fits situations like: tasks that involve Unit testing; tasks that involve Design systems.

How do I install Write Unit Tests in Claude Code?

Run `npx skills add razorpay/blade --skill write-unit-tests -a claude-code`. Or copy the skill folder (.agents/skills/write-unit-tests in razorpay/blade) into .claude/skills/write-unit-tests in your project. Claude Code loads it when a task matches its description.

How do I install Write Unit Tests in Codex?

Run `npx skills add razorpay/blade --skill write-unit-tests -a codex`. Or copy the skill folder (.agents/skills/write-unit-tests in razorpay/blade) into .agents/skills/write-unit-tests in your project. Codex loads it when a task matches its description.

Can I use Write Unit Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add razorpay/blade --skill write-unit-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/write-unit-tests, .gemini/skills/write-unit-tests, .github/skills/write-unit-tests and .opencode/skills/write-unit-tests in your project.

What does Write Unit Tests need to run?

Going by SKILL.md and its folder, Write Unit Tests needs the command-line tools its instructions call (yarn).

Does Write Unit Tests access the network?

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.

Is Write Unit Tests safe to install?

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.

What licence does Write Unit Tests use?

Write Unit Tests is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Write Unit Tests use?

About 1.2k tokens (SKILL.md is roughly 4.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Write Unit Tests?

Skills that share tags, products or a category with Write Unit Tests: Testing (radix-ng/primitives, 274 stars), Cometchat Android V6 Testing (cometchat/cometchat-skills, 130 stars), Docs Lookup (ProgrammerAnthony/Expert-Coding-Harness, 235 stars) and TDD Workflow (hellangleZ/burn-in-cceverywhere-ralph, 112 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Write Unit Tests?

razorpay (a GitHub organization) maintains it in razorpay/blade, which has 656 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on October 7, 2026.

Source: razorpay/blade on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.