testing

Enforce spy cleanup and isolation in React hook tests with Bun.

434|33|Updated Jul 27, 2025
One-click install
npx skills add https://github.com/udecode/better-convex --skill testing-udecode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/udecode/better-convex/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/udecode/better-convex --skill testing-udecode

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Resolve flaky React hook tests by enforcing consistent spy cleanup and isolation.

Core Features & Use Cases

  • Deterministic hook tests: Ensure spies are cleaned up after each test to prevent cross-test contamination.
  • Bun-centric patterns: Leverage Bun test runner for faster, reliable React hook testing.
  • Structured use cases: Validate custom hooks across components and isolated scopes.

Quick Start

Create a Bun-based React hook test with proper spy cleanup.

Frequently Asked Questions about testing

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

FAQPage Schema
Why are my React hook tests flaky and how do I prevent cross-test contamination?

React hook tests become flaky when spies are not cleaned up between runs, causing cross-file contamination. Enforcing consistent spy cleanup and test isolation ensures deterministic results across custom hook unit tests. This pattern prevents residual mocks from affecting subsequent test scopes.

How do I clean up spies in Bun unit tests for custom React hooks?

To clean up spies in Bun unit tests, apply structured spy lifecycle management patterns after each test case. This ensures spies are removed and isolated scopes are reset, preventing residual mock states from leaking into other custom hook tests and causing unexpected timeouts.

Does Bun work well for testing custom React hooks that require isolation?

Yes, Bun works well for testing custom React hooks by providing a fast test runner that supports deterministic results. When combined with structured spy cleanup routines, Bun enables reliable hook validation across components while maintaining strict cross-file test isolation.

What is the best way to fix hook timeouts in React unit tests?

The best way to fix hook timeouts in React unit tests is to enforce consistent spy cleanup and isolation. Lingering spies from previous tests can cause asynchronous hook behaviors to hang, so managing the spy lifecycle properly restores deterministic test execution.

Do I need additional dependencies to isolate React hook tests with Bun?

No additional dependencies are required to isolate React hook tests with Bun. The Skill focuses on leveraging Bun-centric patterns and structured spy cleanup routines directly, ensuring robust lifecycle management and deterministic test results without external mocking libraries.