Register a test case.
@eryx/test Module
Summary
Classes
Functions
API Reference
Classes
Suite
Properties
Suite.new
Suite:test
Suite:beforeAll
Run once before all tests in this suite.
Suite:afterAll
Run once after all tests in this suite.
Suite:beforeEach
Run before each individual test.
Suite:afterEach
Run after each individual test.
Suite:run
Execute all tests in the suite and print results.
Parameters
Optional Lua pattern. When provided, only tests whose name matches the pattern are executed; the rest are skipped.
Print all tests on an accumulating single line
Returns
pass/fail/skip counts.
Expecter
Properties
Expecter.new
Expecter:toBe
Assert that the returned values equal ... (via ==).
Expecter:toNotBe
Assert that the first returned value does NOT equal value.
Expecter:toExist
Assert that at least one value was returned.
Expecter:toNotBeNil
Assert that the first returned value is not nil (and that something was returned).
Expecter:toBeNil
Assert that the first returned value is nil.
Expecter:toBeTrue
Assert that the first returned value is exactly true.
Expecter:toBeFalse
Assert that the first returned value is exactly false.
Expecter:toBeTruthy
Assert that the first returned value is truthy (not nil and not false).
Expecter:toBeFalsy
Assert that the first returned value is falsy (nil or false).
Expecter:toBeType
Assert that typeof(value) == expected.
Expecter:toHaveLength
Assert that #value == length.
Expecter:toContain
Assert that a string contains item as a plain substring, or that a table contains item as a value.
Expecter:toMatch
Assert that a string matches a Lua pattern.
Expecter:toBeGreaterThan
Expecter:toBeLessThan
Expecter:toBeGreaterThanOrEqual
Expecter:toBeLessThanOrEqual
Expecter:toBeCloseTo
Assert that two numbers are within epsilon of each other (default 1e-9).
Expecter:toError
Assert that a function throws. If match is provided, the error message must match that Lua pattern.
Expecter:toNotError
Assert that a function does NOT throw.
Functions
test.expect
test.skip
Unconditionally skips the current test. Call at the top of a test body to mark it as not-yet-implemented or temporarily disabled.
suite:test("future feature", function()
test.skip("not implemented yet")
end)
Parameters
Optional human-readable reason shown in the test output.
test.skipIf
Conditionally skips the current test when condition is truthy.
Use this for platform-specific tests, tests that require external
services, or environment-dependent checks.
suite:test("unix permissions", function()
test.skipIf(os.platform() == "windows", "unix-only test")
-- ... test code ...
end)
Parameters
When truthy, the test is skipped.
Optional reason shown in the test output.
test.runOne
Load and run a single .test.luau file.
Parameters
The path to the test file.
Run options (exitOnFail, filter).
test.runAll
Run a single test-pass over one or more files and/or directories.
paths may be a single path or a list mixing files and directories.
Directories are walked recursively for files matching *.test.luau;
explicitly named files are run as-is (their suffix is not checked).
Each test file must return a Suite. Results across every path are
aggregated into one unified summary.
-- Run all tests under a directory:
test.runAll("tests/")
-- Run a mix of directories and individual files in one pass:
test.runAll({ "tests/", "src/foo.test.luau" })
-- Run only tests with "crypto" in the name:
test.runAll("tests/", { filter = "crypto" })
Parameters
A path, or a list of files/directories, to test.
Run options (exitOnFail, filter).
Types
RunOptions
Exit the process with code 1 when any test fails. Defaults to true.
Lua pattern matched against test names. Only matching tests run;
the rest are skipped. Equivalent to Jest's -t / --testNamePattern.