Browse the docs

switchboard test

Runs the tests macros declare, sealed off from your Mac, and with --checks looks for the elements and menus they depend on, without acting.

Details #

switchboard test [macro...] [--all] [--checks] [--json] runs the tests that macros carry and prints one line per failure, then a total.

Name macros by id or by name. --all runs every macro that has tests. With no macro and no --all the command stops and says so.

switchboard test "Slugify"
switchboard test --all
switchboard test --all --checks
fail Slugify › lowercases: Expected to give back 'day-412', gave back 'DAY-412'
2 tests, 1 failed

A test is a sealed run: nothing touches your Mac, the clipboard, the network or an extension. The test's given (front app, clipboard, variables, the clock) is all the macro sees, and every step that would act is simulated with the test's samples. Tests need no engine, so they run in CI against a shared Library folder.

With --checks the engine also looks for what each macro depends on (elements, menu items, apps, shortcuts, extensions, called macros, hotkeys) without clicking or pressing anything, and prints a missing line for each one it cannot find. Checks need the engine and the Accessibility permission.

The exit code is 1 when any test fails or a check finds something missing, otherwise 0.

Parameters #

switchboard test [id|name…] [--all] [--checks] [--json] run macros' tests, sealed off from the Mac; --checks also looks for what they depend on

Examples #

# a script that stops when a macro broke
switchboard test --all --checks || echo "a macro needs attention"

Gotchas #

  • A test never blocks a macro from running or being turned on.

  • An element in an app that is not running is skipped, not failed: the line says "Slack isn't running".

  • --json prints the reports instead of lines.

See also #