Skip to content

Dioxus testing library #5324

@hovinen

Description

@hovinen

Feature Request

Right now it's hard to write tests against Dioxus apps following the testing guide. The guide offers two options, both of which have severe limitations:

  • Use dioxus-ssr to render and assert on the resulting DOM. This does not provide any way to interact with the components in the test. As soon as the test needs to click a button, this is no longer an option.
  • Use Playwright to write end-to-end tests. Such tests are very slow and notoriously hard to write and maintain. The resulting tests are in another language such as JavaScript, making it really difficult to instrument the system under test.

I would like writing tests to be really easy, without requiring too much thought into how to set up the test harness. Other frameworks like React and Flutter have dedicated testing libraries, so I propose the same for Dioxus.

Implement Suggestion

I have prepared a PR with a minimal version of such a library. This uses the dioxus-native crate and Blitz to simulate layout and rendering. The test can then interact with the VirtualDom, dispatching events and driving the event loop. It can use the DioxusDocument to which the DOM was rendered to query elements.

See also Discord thread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions