Xpersona
U

Unit Test Automation

CLAWHUB · Unverified

One-click initialization of an AI-driven unit testing environment for frontend projects (supports React/Vue/pure TypeScript/Next.js). Automatically detects p...

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: medium.

clawhub skill install s174e9x7sexxt3hstm8edbvmhd83hnk8:setup-unit-test
  1. Install using `clawhub skill install s174e9x7sexxt3hstm8edbvmhd83hnk8:setup-unit-test` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/hibehero/setup-unit-test before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-hibehero-setup-unit-test/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

49,975 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: setup-unit-test
description: >
  One-click initialization of an AI-driven unit testing environment for frontend projects (supports React/Vue/pure TypeScript/Next.js).
  Automatically detects project framework, installs Vitest + Testing Library + MSW, generates config files,
  and injects Claude Code custom commands for cross-project reuse.

  Trigger scenarios:
  (1) Need to initialize unit testing in a new or existing project.
  (2) User says "initialize unit tests", "configure test environment", or "setup unit test".
  (3) Need to enable /gen-unit-test and other AI test generation commands in the project.
  (4) Need a single command to set up test configurations across multiple tech stacks (React/Vue/Next.js/TS).
---

## Security & Permissions Statement

This skill performs the following privileged operations to automate test environment configuration:
- **File System**: Reads `package.json` and writes config files (`vitest.config.ts`, `.claude/commands/*.md`).
- **Shell Execution**: Runs `npm/yarn/pnpm` commands to install dependencies, and runs `git` commands to detect staged files.
- **Git Hooks**: Initializes Husky and modifies `.husky/pre-commit` to automate the testing workflow.

**All scripts run locally and will not transmit project data to external servers (unless explicitly sent to Claude via a command invocation).**

---

# Initialize Unit Testing Environment

One-click setup of a production-grade unit testing solution for any frontend project. Detect environment → Install enhanced plugins → Auto alias resolution → AI command injection.

## Workflow

### Step 1: Detect Project Environment

Run the detection script to identify project details:

```bash
node <skill-dir>/scripts/detect-framework.mjs <project-dir>
```

Returns JSON containing: `os`, `framework`, `isNext`, `typescript`, `hasTsConfig`, `packageManager`, `hasGit`, `hasVitest`, etc.

### Step 2: Install Enhanced Dependencies

Install dev dependencies (`-D`) using the corresponding package manager. Skip already-installed dependencies.

**Core Toolchain**:
- `vitest`
- `@vitest/ui` (visual test interface)
- `@vitest/coverage-v8` (code coverage)
- `jsdom` (browser environment simulation)
- `msw` (API network request mocking)
- `vitest-tsconfig-paths` (auto-resolve path aliases from tsconfig.json)

**Additional for React/Next.js projects**:
- `@testing-library/react`
- `@testing-library/jest-dom`
- `@testing-library/user-event`
- `@vitejs/plugin-react`

**Additional for Vue projects**:
- `@testing-library/vue`
- `@testing-library/jest-dom`
- `@testing-library/user-event`
- `@vitejs/plugin-vue`

### Step 3: Generate Smart Config Files

#### vitest.config.ts

Uses the `tsconfigPaths()` plugin for "zero-config alias resolution".

```typescript
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import vue from '@vitejs/plugin-vue'
import tsconfigPaths from 'vitest-

_meta.json

{
  "ownerId": "kn7085725qqkvr3t8f3ayh3vwn832xc2",
  "slug": "setup-unit-test",
  "version": "2.0.2",
  "publishedAt": 1774322306796
}

references/fix-test-prompt.md

# Test Failure Repair Rules

> This file is written to the project's .claude/commands/fix-test.md by /setup-unit-test

## Input

The file path of the currently failing test or the output from the most recent test run.

## Workflow

1. Run the failing test and capture the complete error output.
2. Classify the failure cause:
   - **Test code bug**: Incorrect selector/assertion/mock → automatically fix the test code.
   - **Source code bug**: Business logic does not match expectations → output a diagnostic report and suggest fixes.
   - **Environment issue**: Timeout/missing dependency → flag and re-run.
3. After automatic repair, re-run to verify (up to 3 rounds).
4. Output a repair summary.

references/gen-unit-test-prompt.md

# AI Unit Test Generation Rules

> This file is written to the project's .claude/commands/gen-unit-test.md by /setup-unit-test

## Input

Analyze the path specified by $ARGUMENTS. Supports the following modes:

- **Single file**: `/gen-unit-test src/utils/format.ts` → generate tests for that file
- **Directory**: `/gen-unit-test src/services/` → scan all source files in the directory and generate tests one by one
- **Full scan**: `/gen-unit-test src/` → scan the entire src directory and generate tests for files missing them
- **No arguments**: `/gen-unit-test` → equivalent to `/gen-unit-test src/`

## Workflow

1. Determine the input type (file / directory):
   - If a directory, recursively scan all `.ts` / `.tsx` / `.vue` files (excluding `.test.`, `.spec.`, `.stories.`, `index.ts`, etc.).
   - For each file, check whether a corresponding test file already exists under `tests/unit/`; skip if it does.
2. For each source file to generate tests for:
   a. Read the source code and extract all exported functions/classes/components.
   b. Analyze parameter types, return values, branch paths, and external dependencies.
   c. Determine the test type:
      - Pure function → Vitest unit test
      - React component → @testing-library/react component test
      - Vue component → @testing-library/vue component test
      - API call → MSW mock integration test
      - Custom Hook/Composable → renderHook test
   d. Generate the test file according to the specification, including:
      - Happy Path (at least 1)
      - Boundary values (at least 2)
      - Error paths (at least 1)
3. Run `vitest run <generated test file>` to verify.
4. If it fails, analyze the error and auto-repair (up to 3 rounds).
5. After all tests pass, output a generation summary: which files were generated, pass/fail counts.

## Framework Requirements

- Use Vitest (`import { describe, it, expect, vi } from 'vitest'`).
- Use @testing-library/react or @testing-library/vue for component tests (based on the project framework).
- Use MSW (Mock Service Worker) for API mocking.
- Follow the AAA pattern (Arrange-Act-Assert).

## Coverage Requirements

- Every exported function/component must cover:
  1. Happy Path (normal input → expected output).
  2. Boundary values (null, zero, extremely large/small values).
  3. Error paths (invalid input → expected error).
  4. Branch coverage (at least one test case per if/switch branch).

## Naming Conventions

- describe: Name of the function/component under test.
- it: "should [verb] [expected behavior] when [condition]".
- Example: `it('should return 0 when both arguments are 0')`.

## Mocking Conventions

- Prefer MSW to intercept network requests rather than directly mocking modules.
- Use `vi.fn()` only for callback function verification.
- Never mock the internal implementation of the module under test.

## File Conventions

- Test files are centralized in the `tests/unit/` directory, mirroring the source code structure by module.
- Unit tests: `

skill-card.md

## Description:

One-click initialization of an AI-driven unit testing environment for frontend projects, with support for React, Vue, pure TypeScript, and Next.js.

This skill is ready for commercial/non-commercial use.

## Publisher:

[hibehero](https://clawhub.ai/user/hibehero)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to initialize and maintain Vitest-based unit testing in frontend projects. It detects the project framework, prepares testing configuration, adds reusable Claude Code test-generation prompts, and can wire project-scoped pre-commit checks.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill can modify a project by adding test dependencies, Vitest setup files, Claude Code command prompts, and a Husky pre-commit hook.

Mitigation: Review the generated files and hook changes before committing or enabling them in repositories that require team approval.

Risk: AI-assisted test generation and repair may produce tests that are incorrect or that hide source-code defects.

Mitigation: Inspect generated tests, review any source-code diagnostics, and rerun the test suite and coverage checks before relying on the results.

## Reference(s):

- [Unit Test Automation ClawHub Page](https://clawhub.ai/hibehero/skills/setup-unit-test)
- [AI Unit Test Generation Rules](artifact/references/gen-unit-test-prompt.md)
- [Test Failure Repair Rules](artifact/references/fix-test-prompt.md)

## Skill Output:

**Output Type(s):** [Text, Markdown, Code, Shell commands, Configuration, Guidance]

**Output Format:** [Markdown guidance with shell commands, JSON detection output, and generated project files]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May install development dependencies and write Vitest setup files, Claude Code command prompts, and a Husky pre-commit hook inside the target project.]

## Skill Version(s):

2.0.2 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Unit Test Automation and adjacent AI workflows.