DeleteRequest
The DELETE method requests that the origin server remove the association between the target resource and its current functionality.
Extends:
Examples:
import { Actor } from '@serenity-js/core';
import { CallAnApi, DeleteRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
import { Ensure, equals, startsWith } from '@serenity-js/assertions';
const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
actor.attemptsTo(
// create a new test user account
Send.a(PostRequest.to('/users').with({
login: 'tester',
password: 'P@ssword1',
}),
Ensure.that(LastResponse.status(), equals(201)),
Ensure.that(LastResponse.header('Location'), startsWith('/users')),
// delete the test user account
Send.a(DeleteRequest.to(LastResponse.header('Location'))),
Ensure.that(LastResponse.status(), equals(200)),
);
Tests:
Static Method Summary
Static Public Methods | ||
public static |
to(resourceUri: Answerable<string>): DeleteRequest Configures the object with a destination URI. |
Method Summary
Public Methods | ||
public |
using(config: Answerable<AxiosRequestConfig>): DeleteRequest |
Inherited Summary
From class HTTPRequest | ||
public |
subject: string |
|
public |
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig> |
Static Public Methods
public static to(resourceUri: Answerable<string>): DeleteRequest source
Configures the object with a destination URI.
When the resourceUri
is not a fully qualified URL but a path, such as /products/2
,
it gets concatenated with the URL provided to the Axios instance
when the CallAnApi Ability was instantiated.
Params:
Name | Type | Attribute | Description |
resourceUri | Answerable<string> | The URI where the Actor should send the HTTPRequest. |
Public Methods
public using(config: Answerable<AxiosRequestConfig>): DeleteRequest source
Params:
Name | Type | Attribute | Description |
config | Answerable<AxiosRequestConfig> | Axios request configuration overrides |