take
IO capture for Gleam tests. Intercepts stdout, stderr, or both and returns
the captured output as a string. Works on both Erlang and JavaScript targets.
If your callback returns a
Promise, usetake_promiseinstead.
Usage
gleam add --dev take@1import take
pub fn prints_greeting_test() {
let #(result, output) = take.with_stdout(fn() {
io.println("Hello, world!")
42
})
assert 42 == result
assert "Hello, world!\n" == output
}
pub fn just_the_output_test() {
assert "Hello, world!\n" == take.capture_stdout(fn() {
io.println("Hello, world!")
})
}Semantic Versioning
Take follows Semantic Versioning 2.0.