TestClient

zio.http.TestClient
See theTestClient companion class
object TestClient

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TestClient.type

Members list

Type members

Inherited types

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def addRequestResponse(request: Request, response: Response): ZIO[TestClient, Nothing, Unit]

Adds an exact 1-1 behavior

Adds an exact 1-1 behavior

Value parameters

request

The request that will trigger the response

response

The response to be returned when a user submits the response

Attributes

Example
  TestClient.addRequestResponse(Request.get(URL.root), Response.ok)
def addRoute[R](route: Route[R, Response]): ZIO[R & TestClient, Nothing, Unit]

Adds a route definition to handle requests that are submitted by test cases

Adds a route definition to handle requests that are submitted by test cases

Type parameters

R

Environment of the new route

Value parameters

route

New route to be added to the TestClient

Attributes

Example
  TestClient.addRoute { Method.ANY / trailing -> handler(Response.ok) }
def addRoutes(routes: Routes[Any, Response]): ZIO[TestClient, Nothing, Unit]
def addRoutes[R](route: Route[R, Response], routes: Route[R, Response]*): ZIO[R & TestClient, Nothing, Unit]

Adds routes to handle requests that are submitted by test cases

Adds routes to handle requests that are submitted by test cases

Type parameters

R

Environment of the new route

Value parameters

routes

New routes to be added to the TestClient

Attributes

Example
 TestClient.addRoutes {
   Routes(
     Method.GET / trailing          -> handler { Response.text("fallback") },
     Method.GET / "hello" / "world" -> handler { Response.text("Hey there!") },
   )
 }
def installSocketApp(app: WebSocketApp[Any]): ZIO[TestClient, Nothing, Unit]

Concrete fields

val layer: ZLayer[Any, Nothing, TestClient & Client]