Last active
September 1, 2024 15:53
-
-
Save huksley/4f3d2455d65e154d4fb296fca4e49897 to your computer and use it in GitHub Desktop.
Test container withLogConsumer does not stream any logs
This file contains 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
const { GenericContainer } = require("testcontainers"); | |
const container = new GenericContainer("ubuntu:latest") | |
.withLogConsumer(consumer => { | |
consumer.on("data", data => { | |
console.log("LOG", data.toString()); | |
}); | |
consumer.on("err", data => { | |
console.log("ERR", data.toString()); | |
}); | |
}) | |
.withCommand(["/bin/bash", "-c", "while true; do sleep 1; done"]) | |
.withUser("ubuntu") | |
.start() | |
.then(async container => { | |
const result = await container.exec(["echo", "1"]); | |
console.log("RESULT", result); | |
container.stop(); | |
}); |
Author
huksley
commented
Sep 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment