gpui-test

longbridge/gpui-component · updated Apr 8, 2026

$npx skills add https://github.com/longbridge/gpui-component --skill gpui-test
0 commentsdiscussion
summary

GPUI provides a comprehensive testing framework that allows you to test UI components, async operations, and distributed systems. Tests run on a single-threaded executor that provides deterministic execution and the ability to test complex async scenarios. GPUI tests use the #[gpui::test] attribute and work with TestAppContext for basic testing and VisualTestContext for window-dependent tests.

skill.md

Overview

GPUI provides a comprehensive testing framework that allows you to test UI components, async operations, and distributed systems. Tests run on a single-threaded executor that provides deterministic execution and the ability to test complex async scenarios. GPUI tests use the #[gpui::test] attribute and work with TestAppContext for basic testing and VisualTestContext for window-dependent tests.

Rules

  • If test does not require windows or rendering, we can avoid use [gpui::test] and TestAppContext, just write simple rust test.

Core Testing Infrastructure

Test Attributes

Basic Test

#[gpui::test]
fn my_test(cx: &mut TestAppContext) {
    // Test implementation
}

Async Test

#[gpui::test]
async fn my_async_test(cx: &mut TestAppContext) {
    // Async test implementation
}

Property Test with Iterations

#[gpui::test(iterations = 10)]
fn my_property_test(cx: &mut TestAppContext, mut rng: StdRng) {
    // Property testing with random data
}

Test Contexts

TestAppContext

TestAppContext provides access to GPUI's core functionality without windows:

#[gpui::test]
fn test_entity_operations(cx: &mut TestAppContext) {
    // Create entities
    let entity = cx.new(|cx| MyComponent::new(cx));

    // Update entities
    entity.update(cx, |component, cx| {
        component.value = 42;
        cx.notify();
    });

    // Read entities
    let value = entity.read_with(cx, |component, _| component.value);
    assert_eq!(value, 42);
}

VisualTestContext

VisualTestContext extends TestAppContext with window support:

#[gpui::test]
fn test_with_window(cx: &mut TestAppContext) {
    // Create window with component
    let window = cx.update(|cx| {
        cx.open_window(Default::default(), |_, cx| {
            cx.new(|cx| MyComponent::new(cx))
        }).unwrap()
    });

    // Convert to visual context
    let mut cx = VisualTestContext::from_window(window.into(), cx);

    // Access window and component
    let component = window.root(&mut cx).unwrap();
}

Additional Resources

  • For detailed testing patterns and examples, see reference.md
  • For best practices and running tests, see examples.md

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.675 reviews
  • Nia Reddy· Dec 28, 2024

    We added gpui-test from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Henry Farah· Dec 28, 2024

    Useful defaults in gpui-test — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Nia Desai· Dec 12, 2024

    Registry listing for gpui-test matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Shikha Mishra· Dec 8, 2024

    gpui-test has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Meera Menon· Dec 8, 2024

    Useful defaults in gpui-test — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Nia Chawla· Dec 8, 2024

    I recommend gpui-test for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Daniel Abbas· Dec 8, 2024

    gpui-test is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Charlotte Agarwal· Dec 4, 2024

    Keeps context tight: gpui-test is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Rahul Santra· Nov 27, 2024

    gpui-test reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Nia Sethi· Nov 27, 2024

    Solid pick for teams standardizing on skills: gpui-test is focused, and the summary matches what you get after install.

showing 1-10 of 75

1 / 8