Skip to main content

Rust tests

The Convex Backend uses cargo-nextest for running Rust tests in CI, but you can also use standard cargo test commands.

Running all tests

Test a specific package:

Running specific tests

Test a specific test or test group:

Using cargo-nextest

For faster test execution, install and use cargo-nextest:
1

Install cargo-nextest

2

Build tests

3

Run tests

Test environment variables

Some tests may require environment variables. For example, database tests use:

TypeScript tests

Running tests for a specific package

Navigate to the package directory and run tests:

Running a specific test file

Pass the file path to the test command:

Running ESM tests

Some packages have separate ESM tests:

CI testing workflow

The project uses GitHub Actions for continuous integration testing.

Rust CI pipeline

The build and test workflow for Rust:
1

Check dependencies

Verify Cargo.lock is up-to-date:
2

Build JavaScript dependencies

Build JS packages required by the Rust isolate:
3

Build Rust tests

4

Run Rust tests

TypeScript CI pipeline

The test and lint workflow for TypeScript packages:
1

Format check

Check formatting with dprint:
2

Install dependencies

3

Run tests

4

Run ESM tests

5

Run linter

Database tests

Some tests require database services. In CI, these run with Docker containers:

PostgreSQL

Then run tests with:

MySQL

Test development workflow

When developing tests, follow this iterative workflow:
1

Write the test

Create or modify test functions in your package.
2

Run the test

For Rust:
For TypeScript:
3

Iterate and fix

Make changes based on test results and re-run until tests pass.
4

Run full test suite

Before submitting, run the full test suite for your package to ensure no regressions.

Environment setup

Ensure you have the correct environment before running tests:
The Rust nightly version specified in rust-toolchain will be automatically used when you run cargo commands if you installed Rust via rustup.