test: rewrite integration tests in Typescript, using new test harness#1287
Open
lewisdaly wants to merge 3 commits into
Open
test: rewrite integration tests in Typescript, using new test harness#1287lewisdaly wants to merge 3 commits into
lewisdaly wants to merge 3 commits into
Conversation
Additionally, add a new integration testing harness which is responsible for spinning up the test dependencies, and keeps test isolated per-file. This lets us more easily write tests that don't depend on existing database state. We also don't need to now build the central-ledger container docker container, instead run the code directly, which now makes it possible to debug more easily from a local environment.
lewisdaly
requested review from
bushjames,
elnyry-sam-k,
geka-evk,
gibaros,
kalinkrustev,
kleyow,
oderayi,
shashi165 and
vijayg10
as code owners
July 3, 2026 13:56
| logger.info(`saveDatabaseCheckpoint() - creating checkpoint at: ${pathToCheckpoint}`) | ||
|
|
||
| // Dump the database inside the container to a known location. | ||
| const containerTempFile = '/tmp/checkpoint_dump.sql' |
|
|
||
| public static getInstance(): Harness { | ||
| if (!Harness.instance) { | ||
| let run = Math.floor(Math.random() * (100000 - 10000) + 10000) |
lewisdaly
force-pushed
the
integration-test-runner
branch
from
July 11, 2026 17:06
80cf48f to
e8e5940
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Motivation
As we bring TigerBeetle into Mojaloop, I've found the current integration test setup (where the harness lives outside of the runner, dependent on docker, coordinated across a number of shell scripts) to be quite brittle and hard to debug.
Since we want to switch to the native nodejs test runner anyway, we decided it was best to bring this work in now instead of waiting before we bring in TigerBeetle. This improves the speed of local deveopment, and makes the integration tests on CI less brittle.
Additionally, this brings the time it takes to run the integration tests in CI from 17 minutes -> ~6 minutes, with more improvements to be made by increasing the parallelism and tightening timeouts later.
How it Works
Each
*.int.tsfile is an integration test file, and is resonsible for running it's own infrastructure withHarness. (currently mysql, kafka, redis). Actually it's mariadb and redpanda since they give much better startup times.For example:
Since each test file has it's isolated infrastructure, we don't have to code around existing database state, or run the tests in a given order to ensure the database has the expected state.
Other Bits And Pieces
Api Helpers
I've also introduced a
api-helpers.tsfile, which gives us higher level abstractions for doing common things inside of Mojaloop, with sensible defaults. For example, to create and prepare a payment, we can do:Internally, the harness tracks the kafka messages being produced and consumed, and waits until the required messages are produced and consumed, or fails if the incorrect number of messages were produced.
Snapshot Testing
At TigerBeetle, we use snapshot testing extensively as it helps both easily test assertions in our tests, but also give additional context to the API contract to the reader.
For example, it's much easier and more meaningful to the reader to write a snapshot assertion like so:
Than the equivalent assertions:
When we make changes to the API, we can then rerun the tests with
SNAP_UPDATE=1 node --test path/to/file, and the snapshot testing library will update the snapshot for us.AI Assistance Disclosure
AI tools were used in producing part of this contribution.
Tools used: Claude Code
Scope: Claude was used to help analyse existing integration tests, and trace the expected test data passed to different components. All code was handwritten by @lewisdaly.
All AI-generated content has been reviewed, understood, and validated by the author.