Extends Lua's built-in assertions with additional tests, custom assertions, argument matchers, and snapshot capabilities.
Luassert is an assertion library for Lua that extends the language's built-in `assert` function with additional test types, custom assertions, and argument matchers. It solves the problem of limited testing capabilities in native Lua by providing a rich, extensible framework for writing expressive unit tests, often used with testing frameworks like Busted.
Lua developers and testers who need a robust, extensible assertion library for unit testing, particularly those using Busted or similar testing frameworks.
Developers choose Luassert for its seamless integration with Lua's existing `assert`, its extensibility through custom assertions and matchers, and its advanced features like snapshots and custom formatters, which enhance test isolation and debugging.
Assertion library for Lua
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Adds numerous assertion types beyond basic equality, such as `True`, `False`, `errors`, and `same` for deep comparison, as shown in the initial code examples.
Supports custom assertion and matcher creation, allowing domain-specific testing logic, demonstrated with examples like `has_property` and `is_even` in the README.
Snapshots enable reverting test state like spies, stubs, and parameters, ensuring clean isolation between tests, as detailed in the snapshot section.
Custom formatters and parameters like `TableFormatLevel` allow tailored failure messages, useful for debugging complex data structures or binary strings.
Cannot use standard dot chaining with Lua keywords like 'true' or 'function', requiring underscores or capitals, leading to inconsistent and error-prone code, as noted in implementation notes.
Optimized for use with Busted; using it standalone or with other frameworks may require extra setup and lacks seamless integration out-of-the-box.
Creating custom assertions and matchers involves understanding internal state handling and message libraries, which can be complex and time-consuming for new users.