take_promise

Hex.pmHex DocsApache 2.0JavaScript Only

Async IO capture for Gleam tests on JavaScript. Like take, but accepts callbacks that return Promise(a) and awaits them before returning captured output.

Usage

gleam add --dev take_promise@1
import gleam/javascript/promise
import take_promise
pub fn async_greeting_test() {
use #(result, output) <- promise.await(
take_promise.with_stdout(fn() {
io.println("Hello, world!")
promise.resolve(42)
}),
)
assert 42 == result
assert "Hello, world!\n" == output
promise.resolve(Nil)
}

Semantic Versioning

Take Promise follows Semantic Versioning 2.0.