Desktop apps that start slowly
Restarting the app before every test is the safest default, but some desktop apps take seconds to start, or need a library or project opened first. Over a hundred tests, that adds up to minutes. reuse keeps the app open for the whole run and puts it back at its starting point after each test.
apps: editor: macos: { app: /Applications/Editor.app } reuse: on_launch: # after every (re)launch: get to the start state - run: open -a /Applications/Editor.app "${project_dir}/fixtures/sample.proj" - expect: treeitem "sample" check: # before each test: are we at the start? - expect: window "Project Browser"reuse: true is enough if the app needs no on_launch steps.
What happens
Section titled “What happens”- First test: the app launches,
on_launchruns, and the windows open at that point become its baseline. - Before each test:
checkruns. If it fails, the app is relaunched once. - After each test (pass or fail): open menus are closed, then every window, dialog and sheet that isn’t in the baseline (with Cancel, Close, OK or Escape). The test doesn’t need cleanup steps for windows.
- When tidying can’t work (a save prompt, a window that won’t close, a crash) the app is quit and relaunched for the next test. The result says why.
Add discard: true to answer “Don’t Save” prompts instead of relaunching, and steps: for any extra reset of your own.
Data is still yours
Section titled “Data is still yours”reuse puts the windows back, not your data. Each test still sets up and resets the data it changes, as always.
Prove it now and then
Section titled “Prove it now and then”Reused apps can hide a test that depends on what an earlier one left behind. Run without reuse regularly, for example nightly in CI:
sis run --no-reusereuse is for native desktop apps (macos:). Browsers already get a fresh, fast context per test.
