How to Test a Tauri App End-to-End (No WebDriver Needed)
The above below running against Yaak, sped up with idle time removed. Click for the full replay. You can test a Tauri app end-to-end without WebDriver by describing each step in plain language. TestDriver matches each description against screenshots of the installed app, so: you test the same .deb your users install, with nothing compiled into it you don't write or maintain selectors your test…
To conduct end-to-end testing of a Tauri application without the need for a WebDriver, you can utilize a tool called TestDriver. TestDriver allows you to describe each step of the testing process in simple language, which it then matches against screenshots of the installed application. This approach has several advantages:
1. You are testing the exact .deb package that your users will install, without any additional compilation or custom code.
2. You do not need to write or maintain any selectors, as TestDriver reads like a set of instructions you would give to a teammate.
3. The test is easier to understand and maintain, as it reads like a series of steps a user would perform.
The example provided in the source code demonstrates how to install Yaak, an open-source API client built with Tauri, send a request, and check the response. The full project is available on GitHub at testdriverai/example-tauri-app.
One of the main reasons to avoid using WebDriver is that Tauri's testing documentation recommends using WebdriverIO's @wdio/tauri-service, which requires the tauri-plugin-wdio-webdriver to be compiled into your app. This is not the case with TestDriver, which does not require any additional compilation or dependencies.
TestDriver describes elements in the same way a user would see them on the screen. For example, instead of using a WebDriver-style selector like `await $( [aria-label= Send request ] ).click();`, TestDriver uses a description such as `await testdriver . find ( Send button (paper airplane icon) at the right end of the URL bar ).click();`. This approach ensures that the test remains stable even if the markup of the application changes.
The example code shows how to use TestDriver to download and install the .deb file, install the necessary Tauri runtime dependencies, and start the Yaak application. It then describes each step of the testing process, such as finding specific buttons or inputs, entering data, and asserting that the expected results are displayed on the screen.
By using TestDriver for end-to-end testing of Tauri applications, you can achieve a stable, maintainable, and user-friendly testing process without the need for a WebDriver. The documentation provides a detailed example and guides for using TestDriver effectively in your Tauri projects.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.