DioxusLabs / DioxusLabs/dioxus
Dioxus testing library
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
Right now it's hard to write tests against Dioxus apps following the [testing guide](https://dioxuslabs.com/learn/0.7/guides/testing/web). 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](https://testing-library.com/docs/react-testing-library/intro/) and [Flutter](https://api.flutter.dev/flutter/flutter_test/) have dedicated testing libraries, so I propose the same for Dioxus.
## Implement Suggestion
I have prepared a [PR](https://github.com/DioxusLabs/dioxus/pull/5323) 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](https://discord.com/channels/899851952891002890/1455297524960198758).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.