Test a desktop app
Desktop apps are tested exactly like web apps: same steps, same selectors, same results. Only the way the app starts is different. This page uses Calculator, which every Mac has, so you can follow along without building anything.
1. Tell Sisyphus how to start the app
Section titled “1. Tell Sisyphus how to start the app”sisyphus: 1apps: calculator: macos: { bundle: com.apple.calculator }defaults: timeout: 5sA macOS app is named by its bundle id (bundle:), its path (app: ./build/MyApp.app) or an executable (exe: ./target/debug/my-app). Not sure of the bundle id? sis apps lists the apps that are running.
2. Look at it
Section titled “2. Look at it”sis inspect calculatorYou get the same kind of list as on the web: button "All Clear", button "Add", text "Edit field", the menu bar items. In Studio, Inspect shows it next to a screenshot, and Pick in app lets you point at an element in the real app.
3. Write the test
Section titled “3. Write the test”sisyphus: 1name: Calculator adds numbersapp: calculatorsteps: - click: button "All Clear" - each: [7, Add, 5, Equals] as: key do: - click: button "${key}" - expect: text "Edit field" value: "12"each runs the steps inside do: once per item, with the item in ${key}. value: checks a field’s current value.
Menus and keyboard shortcuts work too:
- click: menubaritem "Calculator" - click: menuitem "About Calculator" - expect: dialog >> text "Calculator" - press: Mod+W # ⌘W on macOS4. Run it
Section titled “4. Run it”sis runSisyphus starts Calculator, runs the steps with real mouse clicks and key presses, and quits it afterwards. Desktop tests take over the screen, so they run one at a time, and you shouldn’t use the mouse while they run.
Electron and Tauri apps
Section titled “Electron and Tauri apps”Hybrid apps have a native shell (window, menu bar, dialogs) around web content. Sisyphus sees both as one screen, so one test covers both:
apps: notes: electron: { main: ./main.js } # or executable: ./out/Notes.app/Contents/MacOS/Notes editor: macos: { app: ./src-tauri/target/release/bundle/macos/Editor.app } # a Tauri app- click: menuitem "New Note" # native menu bar- fill: textbox "Title" = Groceries # web content- expect: navigation "Notes list" >> button "Groceries"Slow apps
Section titled “Slow apps”If your app takes seconds to start, or needs a project opened before every test, don’t restart it for each test: add reuse and Sisyphus keeps it open, tidying up between tests. See Desktop apps that start slowly.
Next: Writing good tests.
