gpui-test

Automate GPUI component tests with TestAppContext and VisualTestContext.

12.5k|757|Updated Jun 13, 2024
One-click install
npx skills add https://github.com/longbridge/gpui-component --skill gpui-test-longbridge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpui-test
Source: https://github.com/longbridge/gpui-component/tree/main/.claude/skills/gpui-test
Command: npx skills add https://github.com/longbridge/gpui-component --skill gpui-test-longbridge

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GPUI testing tasks are complex due to asynchronous UI updates, window contexts, and visual validation; gpui-test provides a structured framework to write deterministic tests that exercise components and async behavior.

Core Features & Use Cases

  • Deterministic test context: TestAppContext and VisualTestContext enable predictable execution across app contexts.
  • Async and component testing: Write #[gpui::test] tests for components, async tasks, and UI flows.
  • Visual and distributed testing: Includes patterns for windowed tests and cross-context interactions.
  • Use Case: Validate a dashboard component renders correctly after an async data load.

Quick Start

Run gpui-test tests with cargo test to verify component behavior and async workflows.

Frequently Asked Questions about gpui-test

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

FAQPage Schema
How do I write deterministic GPUI component tests for async UI updates?

Deterministic GPUI component tests use TestAppContext and VisualTestContext to ensure predictable execution across app contexts during asynchronous UI updates. You can write #[gpui::test] tests to validate these async workflows reliably.

Can I run visual tests for window-dependent UI scenarios in GPUI?

Yes, visual tests for window-dependent UI scenarios in GPUI are supported using VisualTestContext. This utility enables structured validation for windowed tests and cross-context interactions to verify rendering behavior.

What is the best way to test a GPUI dashboard component after an async data load?

Testing a GPUI dashboard component after an async data load involves using #[gpui::test] with deterministic test contexts. This approach validates that the component renders correctly once asynchronous tasks complete.

Does testing GPUI components require specific test utilities?

Yes, testing GPUI components requires specific test utilities like TestAppContext and VisualTestContext. These provide the necessary structured framework to handle window contexts and ensure deterministic visual validation.

How do I execute tests for GPUI components and async tasks?

You execute tests for GPUI components and async tasks by running cargo test. This command verifies component behavior and async workflows using the deterministic test contexts provided by the framework.

Why are my GPUI component tests failing due to asynchronous UI updates?

GPUI component tests often fail due to asynchronous UI updates and unpredictable window contexts. Using TestAppContext provides a deterministic test context that enforces predictable execution across app states.