Compatibility with Ktor • opensavvy.prepared.compat.ktor • preparedServer
preparedServer
fun preparedServer(configuration: TestApplicationBuilder.(test: TestDsl) -> Unit = {}): PreparedProvider<TestApplication>
Instantiates a Ktor test server.
The server can be configured to add plugins, routes, external services to be mocked, etc. For example:
val server by preparedServer {
install(ContentNegotiation) {
json()
}
externalServices {
hosts("https://www.googleapis.com") {
// …
}
}
routing {
get("/ping") {
call.respondText("Pong")
}
}
}
The configuration lambda is identical to the one passed to the testApplication Ktor function. To learn more, visit the Ktor documentation.