Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
npm i -D testcontainers
Run your app with the DEBUG=testcontainers
env variable set to see debug output.
const redis = require("async-redis");
const { GenericContainer } = require("testcontainers");
(async () => {
const container = await new GenericContainer("redis")
.withEnv("KEY", "VALUE")
.withExposedPorts(6379)
.start();
const redisClient = redis.createClient(container.getMappedPort(6379));
await redisClient.quit();
await container.stop();
})();