So I have a function with this signature (akka.http.model.HttpResponse):
def apply(query: Seq[(String, String)], accept: String): HttpResponse
I simply get a value in a test like:
val resp = TagAPI(Seq.empty[(String, String)], api.acceptHeader)
I want to check its body in a test something like:
resp.entity.asString == "tags"
My question is how I can get the response body as string?
akka-http-testkit
? If yes, you can useentityAs[String]
in the test to get the body as a String value.entityAs[String]
does not work if akka-http-circe'sFailFastCirceSupport
(1.22.0) was brought into context. Work-around was to move the import.