Skip to content
Sign in

How-to

Unit tests

Updated

On this page

Zof runs your repository's own unit tests on every pull request, in an isolated sandbox. You don't need to set up CI for it. A release rule that requires Unit tests is met when your tests run on the pull request's exact commit and pass.

Adding your first test takes about 5 minutes.

What Zof runs

LanguageTest runnerRuntime
JavaScript and TypeScriptJest or VitestNode 22
PythonpytestPython 3.13
PHPPHPUnit or PestPHP 8.2 to 8.5, from composer.json (default 8.4)

Zof finds your tests by itself. For JavaScript and TypeScript it reads package.json and your Jest or Vitest config. For Python it reads pyproject.toml, pytest.ini or setup.cfg. For PHP it reads composer.json, a committed composer.lock and phpunit.xml, and uses Pest when the project has tests/Pest.php or requires pestphp/pest.

Your tests run without network access to your systems and without your secrets. Each run starts clean and is removed afterwards.

Add your first test

If Zof says it couldn't find a test setup it supports, add or fix the setup on the base branch first, then update the pull request's branch.

For JavaScript or TypeScript with Vitest, add Vitest as a dev dependency and a test file:

// sum.test.js
import { test, expect } from 'vitest'
import { add } from './sum.js'

test('adds numbers', () => {
  expect(add(2, 3)).toBe(5)
})

For Python, add pytest to your test dependencies and a test file:

# test_calc.py
from calc import add


def test_add():
    assert add(2, 3) == 5

Check that it worked

Open the pull request on GitHub and look at the Zof / Control check. Its Unit tests line shows one result, and when the tests didn't pass, why and what to do next. The pull request's page in the Zof console shows the same result.

What the result means

Zof showsWhat happenedWhat to do
Unit tests · PassedYour tests ran on this commit and passed.Nothing.
Unit tests · FailedAt least one test failed on this commit, or the tests ran past the time limit.Fix the failing test, then push a commit.
Unit tests · Couldn't runZof couldn't start the tests: no Jest, Vitest, pytest, PHPUnit or Pest project was found, the runtime isn't supported, the build step failed, or the sandbox was busy. The line says which. On a pull request, Zof reads the test setup from the commit the pull request branched from, so a setup added in the same pull request isn't found, even when your own CI runs it. That commit moves only when the branch is rebased on or merged with the base.Follow the line's next step, for example add a test as above, then push a commit. If the pull request adds the setup, merge the setup first, then rebase or merge this branch.
Unit tests · RunningThe tests haven't finished yet. The check updates by itself.Nothing.
Unit tests · Not run yetZof hasn't produced a result for this commit yet.Open the run in the console.

If the release rule is Optional, the line carries an "Optional" tag: a missing or failing unit test is reported but doesn't stop the release. Otherwise the rule is required, and the pull request stays blocked until the tests pass. See Required or optional.

Not supported yet

Planned. When a repository has a test setup but no tests, Zof can write tests for it. Those tests don't count towards a release rule yet.

Other languages, and tests that need a database or other services, aren't supported yet. See What's built.

Next steps