# Unit test

> Unit test is an open-source agent skill for developer tools. Writes frontend component and hook unit tests focused on user behavior. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/ajyadav013/claude-kit/tree/main/skills/unit-test
- **Repository:** https://github.com/ajyadav013/claude-kit
- **GitHub stars:** 13
- **License:** MIT
- **Skill name:** unit-test
- **Collection:** https://github.com/ajyadav013/claude-kit
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

This skill guides the agent through writing unit tests for a frontend component or hook named as an argument. It has the agent read the target code first, then decide what to cover: rendering, prop-driven output, user interactions, loading, empty and error states, and basic accessibility. It also lists things to leave out, such as implementation details, third-party library internals, exact styling classes and snapshot tests.

The workflow covers the test file naming and co-location conventions, a Testing Library based template, a preferred query priority that favors roles and labels over test IDs, and examples for wrapping components in a router or mocking a state store. It also includes patterns for async content and keyboard focus, plus assertion and mocking conventions and suggested coverage targets.

The examples assume React with Testing Library and either Vitest or Jest, along with jsdom and jest-dom. The skill adapts to the project's own runner and framework, and includes setup commands and config samples for those stacks.

## When your agent uses it

> Write unit tests for frontend components and hooks. Follows testing best practices focusing on user behavior over implementation details. Adapts to the project's test runner and component framework.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ajyadav013/claude-kit/tree/HEAD/skills/unit-test)
- [License: MIT](https://github.com/ajyadav013/claude-kit/tree/HEAD/skills/unit-test)

## Features

- **Behavior-first test structure:** Guides tests toward what a user sees and does rather than internal state or private functions.
- **Query priority guidance:** Ranks Testing Library queries from accessible roles down to test IDs as a last resort.
- **Provider and store wrappers:** Shows how to render components inside a router context or mock a state store module.
- **Async and accessibility checks:** Includes patterns for awaiting async content, verifying accessible labels and keyboard focus.
- **Test file conventions:** Covers naming patterns, co-located test placement and assertion preferences.
- **Runner setup examples:** Provides install commands and config samples for Vitest or Jest with Testing Library.

## Good for

- Write unit tests for a React form component
- Add tests for a custom hook that manages local state
- Cover loading, empty and error states of a list component
- Check that buttons and inputs are reachable by role and label in tests
- Set up Vitest or Jest with Testing Library for a frontend project

## Install

### Claude Code

This skill ships in the `claude-kit` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ajyadav013/claude-kit
/plugin install claude-kit@claude-kit
```

Or copy only this skill to `~/.claude/skills/unit-test`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/unit-test &&
cp -R "$tmp/skills/unit-test" ~/.claude/skills/unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/unit-test` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/unit-test` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/unit-test &&
cp -R "$tmp/skills/unit-test" ~/.agents/skills/unit-test &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/unit-test` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/unit-test` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/unit-test &&
cp -R "$tmp/skills/unit-test" ~/.cursor/skills/unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/unit-test` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ajyadav013/claude-kit.git --path skills/unit-test
```

Or copy the folder to `~/.gemini/skills/unit-test` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/unit-test`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/unit-test &&
cp -R "$tmp/skills/unit-test" ~/.copilot/skills/unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/unit-test` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git
```

Then copy `claude-kit/skills/unit-test` into your agent's skills folder as `unit-test`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need to run?

It is invoked with a component or hook name. The project should have a test runner and Testing Library configured; the skill includes install examples for Vitest or Jest.

### Which frameworks does Unit test target?

Its examples use React with Testing Library, and it adapts to the project's own test runner and component framework.

### What does Unit test tell the agent not to test?

Implementation details, third-party library behavior, exact CSS classes, mock data structure and snapshot tests.

### How do I install Unit test in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/unit-test to use it in all your projects, or to .claude/skills/unit-test in one project. Or install the claude-kit plugin, which includes it: /plugin marketplace add ajyadav013/claude-kit, then /plugin install claude-kit@claude-kit.

### Does Unit test run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Unit test?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Unit test?

The closest alternatives to Unit test are React frontend, Jest skill, Test authoring edho ferdian, JavaScript TypeScript jest and React native testing.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [React frontend](https://ai-powered.com/skills/react-frontend): React frontend is an open-source agent skill for developer tools.
- [Jest skill](https://ai-powered.com/skills/jest-skill): Jest skill is an open-source agent skill for developer tools.
- [Test authoring edho ferdian](https://ai-powered.com/skills/test-authoring-edho-ferdian): Test authoring edho ferdian is an open-source agent skill for developer tools.
- [JavaScript TypeScript jest](https://ai-powered.com/skills/javascript-typescript-jest): JavaScript TypeScript jest is an open-source agent skill for developer tools.
- [React native testing](https://ai-powered.com/skills/react-native-testing): React native testing is an open-source agent skill for developer tools.
- [Vitest skill](https://ai-powered.com/skills/vitest-skill): Vitest skill is an open-source agent skill for developer tools.
- [Frontend UI engineering](https://ai-powered.com/skills/frontend-ui-engineering): Frontend UI engineering is an open-source agent skill for developer tools.
- [Test driven development](https://ai-powered.com/skills/test-driven-development-addyosmani): Test driven development is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/unit-test-ajyadav013
