marketplace/productivity

Run the Tests

v0.1.0

@rebindfree

Run npm test, pytest or any command from a global hotkey, with a notice when it passes and a beep when it fails.

Gallery

Run the Tests preview

Readme

Press F5 from any app and your test command runs in your project folder. A notice tells you when it passes and how long it took, and a beep tells you when it does not.

Needs Rebind 3.9.0 or newer on Windows, macOS, or Linux. It requests the exec permission so it can run your command.

Settings

  • Run the tests: default F5. Key changes apply while the package runs.
  • Test command: what to run, such as npm test or pytest. It runs through the system shell (sh -c on macOS and Linux, cmd on Windows).
  • Project folder: where to run it. Left empty, the command runs in Rebind's own working folder, so set it.

Limits

  • Commands run as Rebind's background service, not in your terminal. On macOS the service's PATH is /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin, so tools installed through nvm, volta, or other per-user managers need their full path in the command. On Linux the service runs as root.
  • A run is stopped after 10 minutes. Output is not shown; only the result is.
  • Notices appear in Rebind. To see them on the desktop, turn on Desktop notifications in Rebind's settings; Linux shows them only inside Rebind.
  • Live use remains unverified on Windows, macOS, and Linux.

Stop

Stop the package from the editor toolbar, or press Left Ctrl + Left Alt + K to stop all scripts.

Reviews

No reviews yet. Be the first, from the app.

Source

Version 0.1.0 (current)

main.luau

-- Run the Tests: one key runs your test command in your project folder, with
-- a notice when it passes and a beep when it does not.

local cfg = UI.Schema({
  key = UI.Keybind("F5", { label = "Run the tests" }),
  command = UI.Text("npm test", { label = "Test command" }),
  folder = UI.Text("", {
    label = "Project folder",
    placeholder = "/Users/you/code/app",
  }),
})

local running = false

Bind(
  cfg.key,
  Async(function()
    if running then
      UI.Notify("Tests are still running", "info")
      return
    end
    running = true
    UI.Notify("Running " .. cfg.command, "info")
    local started = os.clock()
    local ok, result = pcall(System.Exec, cfg.command, {
      cwd = if cfg.folder ~= "" then cfg.folder else nil,
      timeout = 600000,
    })
    running = false
    local seconds = string.format("%.1f s", os.clock() - started)
    if not ok then
      UI.Notify(`Tests did not finish: {result}`, "error")
      Audio.Beep()
    elseif result.exit == 0 then
      UI.Notify(`Tests passed in {seconds}`, "success")
    else
      UI.Notify(`Tests failed (exit {result.exit}) in {seconds}`, "error")
      Audio.Beep()
    end
  end)
)