Skip to content
Back to skills

Jest Vitest Unit

ASecurity

Core foundational unit testing methodology for AI coding agents. Focuses on exhaustive edge-case coverage and boundary partitioning.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 7, 2026
ai-agentsjavascripttypescriptgojavatesting

Security analysis

A100/100

Scanned October 7, 2026

npx -y skills add romangalaxys10-spec/fable --skill jest-vitest-unit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Jest Vitest Unit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Jest Vitest Unit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/romangalaxys10-spec-jest-vitest-unit/badge)](https://www.skillsdirectory.com/skills/romangalaxys10-spec-jest-vitest-unit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: jest-vitest-unit
title: Unit Testing & Boundary Value Analysis Patterns
category: Unit & Foundation
testingTypes:
  - Unit
  - Property-Based
frameworks:
  - Vitest
  - Jest
languages:
  - TypeScript
  - JavaScript
author: Pramod Dutta (QASkills.sh)
---

# Unit Testing & Boundary Value Analysis Patterns

Core foundational unit testing methodology for AI coding agents. Focuses on exhaustive edge-case coverage and boundary partitioning.

## Core Mental Model

1. **Equivalence Partitioning & Boundary Value Analysis (BVA)**:
   - For every input range `[min, max]`, systematically test:
     - `min - 1` (Invalid lower boundary)
     - `min` (Valid lower boundary)
     - `min + 1` (Valid nominal lower)
     - `nominal` (Normal happy path value)
     - `max - 1` (Valid nominal upper)
     - `max` (Valid upper boundary)
     - `max + 1` (Invalid upper boundary)
   - Null, undefined, empty array `[]`, empty string `""`, zero `0`, negative numbers, NaN.

2. **AAA Pattern (Arrange, Act, Assert)**:
   - Keep sections visually separated by a single newline.
   - One primary assertion focus per unit test.

3. **Deterministic Timers & Zero Leakage**:
   - Never wait for real wall-clock timeouts in unit tests.
   - Use `vi.useFakeTimers()` and `vi.advanceTimersByTime(ms)`.
   - Restore mocks after each test: `afterEach(() => { vi.restoreAllMocks(); });`.

## Pattern Implementation

```typescript
import { describe, it, expect, vi, afterEach } from 'vitest';
import { calculateDiscount } from '../src/discount';

describe('calculateDiscount()', () => {
  // Boundary tests for tier discount percentage
  it('returns 0% discount for orders under $50 (boundary: $49.99)', () => {
    expect(calculateDiscount(49.99)).toBe(0);
  });

  it('applies 10% discount exactly at $50 threshold (boundary: $50.00)', () => {
    expect(calculateDiscount(50.00)).toBe(5.00);
  });

  it('throws ValidationError when order amount is negative', () => {
    expect(() => calculateDiscount(-1)).toThrowError(/amount must be positive/i);
  });
});
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.