UNPKG

@serenity-js/rest

Version:

Serenity/JS Screenplay Pattern library for interacting with REST and other HTTP-based services, supporting comprehensive API testing and blended testing scenarios

48 lines 1.71 kB
import type { Answerable, AnswersQuestions, CollectsArtifacts, UsesAbilities } from '@serenity-js/core'; import { Interaction } from '@serenity-js/core'; import type { AxiosRequestConfig } from 'axios'; /** * Sends a [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/) to a specified URL. * * The response to the request is made available via [`LastResponse`](https://serenity-js.org/api/rest/class/LastResponse/). * * ## Send a GET request * * ```ts * import { actorCalled } from '@serenity-js/core' * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest' * import { Ensure, equals } from '@serenity-js/assertions' * * await actorCalled('Apisitt') * .whoCan(CallAnApi.at('https://api.example.org/')) * .attemptsTo( * Send.a(GetRequest.to('/books/0-688-00230-7')), * Ensure.that(LastResponse.status(), equals(200)), * ) * ``` * * @group Activities */ export declare class Send extends Interaction { private readonly request; /** * Instantiates a new [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Send`](https://serenity-js.org/api/rest/class/Send/). * * #### Learn more * - [AxiosRequestConfig](https://axios-http.com/docs/req_config) * * @param request */ static a(request: Answerable<AxiosRequestConfig>): Interaction; /** * @param request */ protected constructor(request: Answerable<AxiosRequestConfig>); /** * @inheritDoc */ performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void>; private responseToArtifact; private requestToArtifactName; } //# sourceMappingURL=Send.d.ts.map