Skip to content

Test Runner (ob test)

Orbita ships with a fast, zero-config test runner built right into ob.

Automatic Discovery

Running ob test recursively discovers files matching:

  • *_test.lua, *_test.tyl, *_test.luax
  • *.test.lua, *.test.tyl, *.test.luax

You can also target a specific file or directory:

ob test src/math_test.tyl

Test API

describe, test (aliased as it), and expect are automatically injected into every test file:

-- src/calc_test.tyl
describe("Calculator", function()
    test("typed addition", function()
        local function add(a: number, b: number): number
            return a + b
        end
        expect(add(2, 3)).to_be(5)
    end)

    test("deep table equality", function()
        expect({ a = 1, b = { 2, 3 } }).to_equal({ a = 1, b = { 2, 3 } })
    end)

    test("error assertions", function()
        expect(function()
            error("division by zero")
        end).to_throw("zero")
    end)
end)

Built-in Matchers

Matcher Description
.to_be(expected) Strict equality (==).
.to_equal(expected) Deep recursive equality for tables and values.
.to_contain(needle) Substring check for strings or membership check for arrays.
.to_be_truthy() Asserts the value is Lua truthy.
.to_be_falsy() Asserts the value is false or nil.
.to_throw(substr?) Asserts the function throws an error (optionally matching substr).

Permissions in Tests

Pass standard permission flags when your tests touch the filesystem or network:

ob test --allow-read --allow-write