write-unit-tests

Write Vitest unit tests for BEEQ shared utilities using AAA structure.

160|24|Updated Feb 22, 2023
One-click install
npx skills add https://github.com/Endava/BEEQ --skill write-unit-tests-endava
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-unit-tests
Source: https://github.com/Endava/BEEQ/tree/main/.agents/skills/write-unit-tests
Command: npx skills add https://github.com/Endava/BEEQ --skill write-unit-tests-endava

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you create focused, maintainable Vitest unit tests for BEEQ shared utility code, reducing regressions and making refactors safer.

Core Features & Use Cases

  • Covers helper functions and pure logic in packages/beeq/src/shared/utils/.
  • Uses the AAA pattern to keep tests clear, consistent, and easy to review.
  • Supports mocking functions and browser APIs, managing fake timers, and validating edge cases such as empty inputs, boundary values, and error paths.
  • Ideal for adding tests to new utilities, repairing failing tests after a code change, or improving coverage for tricky behavior.

Quick Start

Use the write-unit-tests skill to generate Vitest tests for the debounce utility in packages/beeq/src/shared/utils/debounce.ts.

Frequently Asked Questions about write-unit-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Vitest unit tests for utility functions?

To write Vitest unit tests for utility functions, structure tests using the AAA pattern, apply vi.fn and vi.spyOn for mocking, and validate edge cases like empty inputs or boundary values.

How does fake timer handling work in Vitest utility tests?

Fake timer handling in Vitest utility tests involves mocking time-dependent functions to control execution, followed by strict cleanup of timers and mocks after each test to prevent state leakage.

What is the best way to mock browser APIs in Vitest?

The best way to mock browser APIs in Vitest is using vi.fn and vi.spyOn to intercept calls, allowing you to simulate API behaviors and validate edge cases while ensuring strict mock cleanup afterward.

Can I use this approach to fix failing regression tests for shared utils?

Yes, you can use this approach to fix failing regression tests for shared utils by rewriting them with the AAA pattern and verifying edge cases or error paths to ensure coverage and stability.

Why should I enforce strict cleanup of mocks and timers after each test?

You should enforce strict cleanup of mocks and timers after each test to prevent state leakage and cross-test contamination, ensuring that fake timers and mocked functions do not affect subsequent test results.