awesome-repositories.com
博客
awesome-repositories.com

通过 AI 驱动的搜索,发现最优秀的开源仓库。

探索精选搜索开源替代品自托管软件博客网站地图
项目关于排名机制媒体报道MCP 服务器
法律隐私政策服务条款
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
testing-library avatar

testing-library/react-hooks-testing-library

0
View on GitHub↗
5,266 星标·230 分支·TypeScript·MIT·13 次浏览react-hooks-testing-library.com↗

React Hooks Testing Library

该项目是一个专门的测试工具和 Mock 实用程序,旨在隔离测试 React Hook。它提供了一个模拟组件环境,用于执行 Hook 逻辑并跟踪返回的值,而无需完整的用户界面。

该库支持验证 Hook 的生命周期,包括挂载、更新和卸载阶段。它具有注入属性以强制重新渲染的机制,以及一个异步等待系统,以确保在运行断言前处理状态更新。

该工具集涵盖了状态管理验证、防止测试间状态泄漏的自动化生命周期清理,以及触发状态更新以验证 Hook 如何响应输入变化的能力。

Features

  • Hook Execution Wrappers - Executes hooks inside a minimal React component to simulate a real lifecycle and access hook state.
  • Custom Hook Testing - Implements a specialized harness for verifying the state transitions and return values of custom hooks in isolation.
  • Hook Return Value Tracking - Captures and tracks the latest return values of hooks during render cycles for external inspection.
  • Hook Mocking Utilities - Provides a framework for injecting props and awaiting asynchronous updates within a simulated React environment.
  • Test Harnesses - Implements a simulated environment (test harness) to validate hook logic without a full UI.
  • Headless Render Cycle Controllers - Manages the timing of hook execution and state updates to ensure predictable behavior in headless environments.
  • Asynchronous Polling Mechanisms - Provides polling mechanisms to wait for asynchronous state updates before running test assertions.
  • Asynchronous Test Handling - Provides capabilities for managing tests that rely on asynchronous hook operations and promise resolutions.
  • React Testing Utilities - Provides specialized utilities for unit testing React hooks in isolation by simulating a component environment.
  • Component Prop Injection - Allows injecting dynamic properties into a wrapper component to trigger hook re-renders and test various inputs.
  • Hook Property Injection - Passes custom arguments and initial values to hooks to verify behavior across different configurations.
  • State Update Triggering - Provides capabilities to simulate user interactions and state changes to verify that hook return values update correctly.
  • Hook Lifecycle Testing - Ensures that effects and cleanup functions within a hook execute correctly across all lifecycle phases.
  • Test State Cleanup - Includes mechanisms to clear hook state and unmount components to prevent pollution between tests.
  • Test Lifecycle Hooks - Provides mechanisms to unmount test components to trigger cleanup effects and hydrate for interaction.
  • Test Lifecycle Hooks - Automatically executes cleanup functions after tests to remove rendered hooks and prevent state leakage.
  • Hook State Verifications - Verifies that a hook correctly manages internal state and updates its output based on changing triggers.
  • State Response Testers - Utilities for verifying how hooks respond to state changes by triggering re-renders and managing cleanup.
  • Test-Controlled State Updates - Executes state updates and effects within a wrapper to ensure all changes finish before assertions.

Star 历史

testing-library/react-hooks-testing-library 的 Star 历史图表testing-library/react-hooks-testing-library 的 Star 历史图表

AI 搜索

探索更多 awesome 仓库

用简单的语言描述您的需求 —— AI 将根据相关性为您从数千个精选开源项目中进行排序。

Start searching with AI

常见问题解答

testing-library/react-hooks-testing-library 是做什么的?

该项目是一个专门的测试工具和 Mock 实用程序,旨在隔离测试 React Hook。它提供了一个模拟组件环境,用于执行 Hook 逻辑并跟踪返回的值,而无需完整的用户界面。

testing-library/react-hooks-testing-library 的主要功能有哪些?

testing-library/react-hooks-testing-library 的主要功能包括:Hook Execution Wrappers, Custom Hook Testing, Hook Return Value Tracking, Hook Mocking Utilities, Test Harnesses, Headless Render Cycle Controllers, Asynchronous Polling Mechanisms, Asynchronous Test Handling。

testing-library/react-hooks-testing-library 有哪些开源替代品?

testing-library/react-hooks-testing-library 的开源替代品包括: callstack/react-native-testing-library — This project is a testing framework designed for React Native applications, providing a suite of tools to render… avajs/ava — Ava is a test runner for JavaScript and TypeScript designed to execute test suites with a focus on concurrency and… thomhurst/tunit — TUnit is a comprehensive C# testing framework, mocking library, and fluent assertion tool. It utilizes source… onsi/ginkgo — Ginkgo is a behavior-driven development testing framework, assertion library, and test runner for Go. It provides a… uber-go/goleak — Goleak is a diagnostic utility designed to identify and report leaked goroutines within Go applications. By… jnicklas/capybara — Capybara is a browser automation testing library and framework for web application acceptance testing. It provides a…

React Hooks Testing Library 的开源替代方案

相似的开源项目,按与 React Hooks Testing Library 的功能重合度排序。
  • callstack/react-native-testing-librarycallstack 的头像

    callstack/react-native-testing-library

    3,390在 GitHub 上查看↗

    This project is a testing framework designed for React Native applications, providing a suite of tools to render components in a controlled memory environment. It enables developers to verify the behavior and structure of mobile interfaces by simulating user interactions and monitoring component lifecycle transitions. By isolating components from the rest of the application, it ensures that tests remain stable and independent. The framework distinguishes itself through an accessibility-first approach, prioritizing user-facing attributes like roles, labels, and text content when querying the c

    TypeScriptjestreactreact-native
    在 GitHub 上查看↗3,390
  • avajs/avaavajs 的头像

    avajs/ava

    20,849在 GitHub 上查看↗

    Ava is a test runner for JavaScript and TypeScript designed to execute test suites with a focus on concurrency and isolation. It serves as a concurrent test executor that runs test files in parallel across multiple processes to reduce total runtime and prevent state leakage between suites. The project features a built-in snapshot testing framework that saves large data structures to disk and compares subsequent executions to detect regressions via diffs. It is also compatible with the Test Anything Protocol, allowing it to export results for use with external reporting tools. Its capability

    JavaScriptassertasyncasync-functions
    在 GitHub 上查看↗20,849
  • thomhurst/tunitthomhurst 的头像

    thomhurst/TUnit

    3,744在 GitHub 上查看↗

    TUnit is a comprehensive C# testing framework, mocking library, and fluent assertion tool. It utilizes source generation for test discovery and mock creation, ensuring compatibility with Native AOT and IL trimming by eliminating the need for runtime reflection and proxies. The framework provides specialized capabilities for integration testing, including the management of distributed application lifecycles, isolated database schemas, and the correlation of telemetry and logs across process boundaries via OTLP. It also includes an HTTP testing utility to intercept network exchanges and mock AP

    C#csharpdotnettest
    在 GitHub 上查看↗3,744
  • onsi/ginkgoonsi 的头像

    onsi/ginkgo

    9,014在 GitHub 上查看↗

    Ginkgo is a behavior-driven development testing framework, assertion library, and test runner for Go. It provides a domain-specific language for writing human-readable specifications, organizing tests into hierarchical containers and subjects to describe system behavior. The project distinguishes itself through advanced execution control and observability, featuring a test runner capable of parallel distribution, sharding, and randomized execution order to detect flaky tests. It includes specialized diagnostic tools for goroutine leak detection, hanging spec monitoring, and failure state debu

    Go
    在 GitHub 上查看↗9,014
  • 查看 React Hooks Testing Library 的所有 30 个替代方案→