These projects from the OPA ecosystem help with or support running of tests on Rego code.

Regal is a useful step to use when testing Rego policies to ensure code is correct and free of common errors. See the README to get started.

Conftest supports unit testing of policy and has a number of extra language features for working with configuration files. The functionality is documented here.
Vulnetix ships with 250+ built-in Rego rules spanning SCA, IaC, container,
secrets, SAST, license and SBOM checks, and lets teams extend coverage
with their own policy-as-code rule repositories via the --rule flag.
See the
Code Scanner docs
for details.

The rego-test-assertions library contains various assertion functions, which will print the expected result vs. the outcome to the console on failure.

GitHub Action for OPA Rego Policy Tests automates testing for your OPA (Open Policy Agent) Rego policies, generates a report with coverage information, and posts the test results as a comment on your pull requests, making it easy for your team to review and approve policies.