Testcontainers became a popular way of setting up dependencies for integration testing. They’re not ideal, as configuring them to run your tests eff

How to configure a custom Test Container on the EventStoreDB example - Event-Driven.io

submited by
Style Pass
2024-04-28 14:00:04

Testcontainers became a popular way of setting up dependencies for integration testing. They’re not ideal, as configuring them to run your tests efficiently is not as trivial as it’s glossed; I explained that in A simple way to configure integration tests pipeline. Still, undeniably, it can speed up the initial ramp-up phase and, if used wisely, can be a decent way to handle common testing dependencies.

Testcontainers already provide the default configurations for tools like PostgreSQL, Kafka, MongoDB etc. Yet, sometimes you need to use something a bit less mainstream, for instance, EventStoreDB as your event store. How to do it?

Luckily, test Containers provide a built-in way of handling such cases, providing a generic abstraction for that: GenericContainer. We can extend it to provide our test container. Let’s see how to do it using Typescript.

We need to start by adding two classes, one representing a container image configuration and the other representing a started container instance.

Leave a Comment