import {Send} from '@serenity-js/rest/lib/screenplay/interactions'
public class | source

Send

Sends a HTTPRequest to a specified url. The response to the request is made available via the LastResponse Questions.

Extends:

Interaction → Send

Examples:

Send a GET request
 import { Actor } from '@serenity-js/core';
 import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
 import { Ensure, equals } from '@serenity-js/assertions';

 const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));

 actor.attemptsTo(
     Send.a(GetRequest.to('/books/0-688-00230-7')),
     Ensure.that(LastResponse.status(), equals(200)),
 );

Tests:

Static Method Summary

Static Public Methods
public static

a(request: Answerable<AxiosRequestConfig>): Interaction

Instantiates a new Send Interaction.

Constructor Summary

Public Constructor
public

constructor(request: Answerable<AxiosRequestConfig>)

Method Summary

Public Methods
public

performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void>

Makes the provided Actor perform this Interaction.

public

toString(): string

Generates a description to be used when reporting this Activity.

Public Constructors

public constructor(request: Answerable<AxiosRequestConfig>) source

Params:

NameTypeAttributeDescription
request Answerable<AxiosRequestConfig>

Public Methods

public performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void> source

Makes the provided Actor perform this Interaction.

Params:

NameTypeAttributeDescription
actor UsesAbilities & CollectsArtifacts & AnswersQuestions

Returns:

Promise<void>

public toString(): string source

Generates a description to be used when reporting this Activity.

Returns:

string