Node.js-based test runner for Docker images using Testcontainers.
This image provides a consistent test execution environment for all Docker images in this repository. It includes Node.js and the testcontainers library for running integration tests against Docker containers.
- Node.js 25 Alpine: Lightweight Node.js runtime
- testcontainers: Node.js library for container-based testing
- Pre-installed dependencies: testcontainers module dependencies for faster test execution
Test files are mounted at runtime from each image directory (e.g., images/ci-helm/ci-helm.test.js).
Run tests for a specific image:
make test <image-name>This will:
- Build the image to test
- Build the testcontainers-node Docker image
- Mount the image directory, run tests, and write
junit.xml
Tests are automatically run in CI for each image. The testcontainers-node image is built once and used to test all images.
Each image that has tests should include an <image-name>.test.js file in its directory:
images/
βββ ci-helm/
β βββ Dockerfile
β βββ ci-helm.test.js
βββ mydumper/
β βββ Dockerfile
β βββ mydumper.test.js
βββ testcontainers-node/
βββ Dockerfile
βββ package.json
βββ README.md
Tests use Node.js built-in test runner with testcontainers:
import { describe, it } from "node:test";
import assert from "node:assert";
import { GenericContainer } from "testcontainers";
describe("My Image", () => {
it("should have required tool installed", async () => {
const testedImageRef = process.env.TESTED_IMAGE_REF;
if (!testedImageRef) {
throw new Error("TESTED_IMAGE_REF environment variable is required");
}
const container = await new GenericContainer(testedImageRef)
.withCommand(["sleep", "infinity"])
.start();
try {
const { exitCode, output } = await container.exec(["tool", "--version"]);
assert.strictEqual(exitCode, 0);
assert.match(output, /version/);
} finally {
await container.stop();
}
});
});- Dedicated Docker image: Contains Node.js runtime and testcontainers dependencies
- Runtime mounting: Test files are mounted at runtime, not copied into the image
- Single package.json: All test dependencies managed in one place
- Docker-based execution: Tests always run via Docker (both locally and in CI)
- JUnit output: Each run emits
junit.xmlalongside the image tests for CI parsing
This approach ensures:
- β Simple DevX (Docker + Make only)
- β Consistent test environment
- β Fast test execution with pre-installed dependencies
- β Easy maintenance with colocated tests