tiniest is a collection of minimal, portable testing libraries for Luau,
built on a few principles:
- Simple, idiomatic Luau throughout.
- Zero external dependencies.
- Small core, extend with plugins.
- Runtime independence.
- No opinions about project structure.
tiniest comes with pre-configured bundles for popular runtimes like Roblox and
Lune, or pick and mix your own modules and plugins!
test()anddescribe()callbacks- Clean, correctly-cropped stack traces
- Declarative
expect()API with line numbers and code visualisation - Pretty-formatted summaries of reports with emoji, Unicode, and colour
- Benchmark how long tests run for
- Extensible, lightweight plugin system
- Snapshot testing for all quotable data types
- Test discovery for Lune
No installation needed!
tiniest is distributed as a set of portable Luau files that sit next to each
other. Drop them into your lib folder, keep the ones you need, and start using
tiniest right away :)
π¨ The printed reports come with colour - try it in your terminal!
Here's an example file written with tiniest_for_lune:
--!strict
local tiniest = require("@tiniest_for_lune").configure({
snapshot_path = "./test/__snapshots__",
save_snapshots = true
})
local function my_test_suite()
local describe = tiniest.describe
local test = tiniest.test
local expect = tiniest.expect
local snapshot = tiniest.snapshot
describe("some cool features", function()
test("it works", function()
expect(2 + 2).is(4)
end)
test("snapshots", function()
snapshot({
hello = "world",
foo = true,
bar = 2
})
end)
end)
end
local tests = tiniest.collect_tests(my_test_suite)
tiniest.run_tests(tests, {})The above example generates a report like this and prints it to stdout:
ββββββββββββββββββββββββββββββ Status of 2 test(s) βββββββββββββββββββββββββββββ
β
some cool features βΈ it works - 74.9Β΅s
β
some cool features βΈ snapshots - 137.71ms
ββββββββββββββββββββββββββββββ 2 passed, 0 failed ββββββββββββββββββββββββββββββ
Time to run: 217.9ms
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Failures look like this:
βββββββββββββββββββββββββββββ Errors from 2 test(s) ββββββββββββββββββββββββββββ
β some cool features βΈ it works
Expectation not met
β
16 β expect(4).is(5)
β
[string "test/test_main"]:16
β some cool features βΈ snapshots
Snapshot does not match
β
78 β snapshot({
β ["bar"] = 2;
β ["foo"] = true;
β ["hello"] = "world";
β })
β
β -- snapshot on disk:
β snapshot({
β ["bar"] = 5;
β ["foo"] = false;
β ["hello"] = "earth";
β })
β
[string "test/test_main"]:20
ββββββββββββββββββββββββββββββ Status of 2 test(s) βββββββββββββββββββββββββββββ
β some cool features βΈ it works - 111.6ms
β some cool features βΈ snapshots - 174.9ms
ββββββββββββββββββββββββββββββ 0 passed, 2 failed ββββββββββββββββββββββββββββββ
Time to run: 292.81ms
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Licensed the same way as all of my open source projects: BSD 3-Clause + Security Disclaimer.
As with all other projects, you accept responsibility for choosing and using this project.
See LICENSE or the license summary for details.