preparedServer

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.

See also

Instantiate a client from this server.