Skip to main content
Test scripts let you write unit tests for your helper functions (see Blank Scripts) and run them directly in the Rive editor. Use them to verify math helpers, string utilities, or any other pure logic your scripts depend on. Beyond validating your code, tests also serve as precise instructions for the AI Agent, helping it produce code that behaves exactly as you intend.

Creating a Test Script

Create a new script and select Test as the type.

Anatomy of a Test Script

A Test script exposes a single setup(test: Tester) function. The Tester object gives you helpers to define and group tests:
  • test.case(name, fn) – define a single test case.
  • test.group(name, fn) – group related tests. Groups can be nested.
  • expect(value) – create an expectation object to assert on a value.
Inside a case, the expect function is passed as an argument to your test callback.

Example

Tip: Use descriptive names for your groups and cases. They show up in the test results panel and make it easier to see what failed.

Matchers (expectations)

The expect helper returns an object with matcher methods you can use in your tests, for example:
For a complete list of matchers and test utilities, see Test API Reference (TODO: link).

Inverting matchers with never

You can invert any matcher by chaining .never before it. This means: the test passes only if the matcher would normally fail.

Running tests

  1. In the Assets panel, right-click your Test script.
  2. Select Run Tests.
To run every test script in the file, open the Testing tab in the Debug Panel and click Run All Tests. This compiles all scripts first, and lists the results in the Testing tab. Test results are shown:
  • Passing and failing cases are listed under the script in the Assets Panel
  • Passing and failing cases are highlighted in the script editor
In the Assets panel, each test shows whether it passed or failed the last time it ran. Expand a failed test to see which checks failed, then select a failed check to jump to that line in the script. Problems panel