kafka-tesing-toolkit
v0.1.0
Published
Small, practical Kafka test helpers and a local Docker broker lifecycle for Node.js test suites.
Maintainers
Readme
kafka-tesing-toolkit
Kafka integration-test helpers for Node.js and TypeScript.
Install
npm install kafka-tesing-toolkit kafkajsStart a local broker
Docker must be installed and running.
import { startLocalKafka } from "kafka-tesing-toolkit";
const broker = await startLocalKafka();
// Connect KafkaJS with brokers: [broker.bootstrapServers]
await broker.stop();Publish and consume test messages
import { Kafka } from "kafkajs";
import { createKafkaTestContext } from "kafka-tesing-toolkit";
const kafka = new Kafka({ clientId: "my-test", brokers: ["localhost:9092"] });
const context = await createKafkaTestContext(kafka);
await context.createTopic("orders");
await context.publish("orders", { id: 42 });
const message = await context.consume<{ id: number }>("orders");
await context.close();The package is intentionally small: it provides repeatable broker startup plus common publish/consume operations, while leaving test-runner choice to the consuming project.
