Skip to content
Agentmart
Submit a tool

unit-tests

Use when writing or reviewing JavaScript/TypeScript unit tests with Vitest, for BDD structure, AAAR comments, and coverage/mocking conventions.

Skill by ioncache

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/ioncache-unit-tests

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when writing or reviewing JavaScript/TypeScript unit tests with Vitest, for BDD structure, AAAR comments, and coverage/mocking conventions. Opinionated, assumes Vitest.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/unit-tests

What's inside

Skill name
unit-tests
Description
Use when writing or reviewing JavaScript/TypeScript unit tests with Vitest, for BDD structure, AAAR comments, and coverage/mocking conventions. Opinionated, assumes Vitest.
License
MIT
Instructions
140 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Unit Testing Standards (Vitest)

**Applies to:** JavaScript/TypeScript with Vitest.

## Core Principles

1. Use AAAR (Arrange, Act, Assert, Revert) comments for test clarity
2. Aim for 100% coverage; use `/* istanbul ignore next */` with justification
3. BDD format: `describe()` blocks + `it()` (NEVER use `test()`)
4. Test titles MUST start with `should` and describe behavior
5. Colocate tests with the source file they cover

## Test Structure

```javascript
import { describe, it, expect, beforeEach } from 'vitest'
import { functionToTest } from './moduleToTest'

describe('moduleToTest.js', () => {
  describe('functionToTest', () => {
    it('should do something specific when given certain input', () => {
      // Arrange
      const input = 'test'

      // Act
      const result = functionToTest(input)

      // Assert
      expect(result).toBe('expected')
    })
  })
})
```

## Coverage & Mocking

**Coverage:** Use `/* istanbul ignore next */` only when necessary (error
boundaries, third-party code, platform-specific, E2E-tested UI). Add a comment
explaining why.

**Mocking:** Avoid when possible. If needed, mock at the lowest level and
document why. Prefer refactoring for testability:

```javascript
// Before: requires mocking Date
function getCurrentTime() {
  return new Date().toISOString()
}

// After: testable via dependency injection
function getCurrentTime(date = new Date()) {
  return date.toISOString()
}
```

## Test Execution (MANDATORY)

**After ANY test file change** (new tests, edits, refactors), you MUST:

1. Run the modified test file
2. Fix failures
3. Repeat until green

Do not consider test changes complete until tests pass.

## BDD Format Requirements

- Use `describe()` for context and unit under test
- Use `it()` for test cases (NEVER use `test()`)
- Titles MUST start with `should` + observable behavior
- One behavior per test when possible

```javascript
describe('Calculator', () => {
  describe('add', () => {
    it('should return sum of two positive numbers', () => {})
    it('should handle negative numbers correctly', () => {})
    it('should throw error for non-numeric input', () => {})
  })
})
```

## AAAR Comments

Use in every non-trivial test:

- `// Arrange`, setup/given
- `// Act`, when
- `// Assert`, then
- `// Revert`, cleanup (or use `afterEach`)

Simple tests with obvious steps may omit these.

## Example Test

```javascript
import { describe, it, expect, beforeEach } from 'vitest'
import { processRanges } from './labResults'

describe('labResults.js', () => {
  describe('processRanges', () => {
    let ranges, value, options

    beforeEach(() => {
      // Arrange
      ranges = {
        optimal: [[0, 10]],
        warning: [[11, 20]],
        danger: [[21, 30]]
      }
      value = 15
      options = {}
    })

    it('should return correct range info for value in warning range', () => {
      // Act
      const result = processRanges(ranges, value, options)

      // Assert

From ioncache/ioncache-ai-tools, MIT.

More from ioncache/ioncache-ai-tools

Signals

Stars
0
Forks
0
Open issues
3
Last commit (this folder)
Jul 29, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from ioncache

Cite this page

unit-tests skill. Agent Mart. https://agentmart.dev/skills/ioncache-unit-tests (last updated 2026-10-24)