Testing
RunWithDrivine runs each test of a file in its own transaction, rolled back at its end, so tests leave nothing behind:
RunWithDrivine({ rollback: true });
describe('RouteRepository', () => { it('finds the fastest route', async () => { // … });});FalkorDB has no transactions to roll back: clear what a test wrote yourself.
Test Containers, or a Local Instance
Section titled “Test Containers, or a Local Instance”@liberation-data/drivine/testing starts a Testcontainer for each datasource your
test environment configures, and points the datasource at it: Neo4j, Memgraph, FalkorDB, Postgres and Oracle. While you
iterate, USE_LOCAL_<TYPE>=true uses an instance of your own in that type’s place, so nothing starts and you can look at
what a test left behind. It is drivine4j’s @EnableDrivineTestConfig. Add testcontainers to your dev dependencies, and
make it Jest’s global setup and teardown:
import { drivineGlobalSetup } from '@liberation-data/drivine/testing';require('dotenv').config({ path: '.env.test' });export default drivineGlobalSetup;
// test/global-teardown.tsexport { drivineGlobalTeardown as default } from '@liberation-data/drivine/testing';npm test # a container for each datasourceUSE_LOCAL_NEO4J=true npm test # Neo4j at DATABASE_HOST:DATABASE_PORT, the others in containersDatasources of one type share a container. <TYPE>_TEST_IMAGE picks another image. See
TEST_CONTAINERS.md, which also covers running Drivine’s own suite.

