How to use the @serenity-js/rest.LastResponse.body function in @serenity-js/rest

To help you get started, we’ve selected a few @serenity-js/rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jan-molak / serenity-js / packages / local-server / spec / servers.spec.ts View on Github external
prepare(actor: Actor): Actor {
                    return actor.whoCan(
                        ManageALocalServer.runningAHttpListener(handler()),
                        CallAnApi.using(axios.create()),
                    );
                }
            }

            Nadia = stage(new Actors()).theActorCalled('Nadia');

            return expect(Nadia.attemptsTo(
                StartLocalServer.onRandomPort(),
                Ensure.that(LocalServer.url(), startsWith('http://127.0.0.1')),
                Send.a(GetRequest.to(LocalServer.url())),
                Ensure.that(LastResponse.status(), equals(200)),
                Ensure.that(LastResponse.body(), equals('Hello World!')),
            )).to.be.fulfilled;                                                  // tslint:disable-line:no-unused-expression
        });
github jan-molak / serenity-js / examples / cucumber-rest-api-level-testing / features / support / screenplay / tasks / VerifyResultAt.ts View on Github external
export const VerifyResultAt = (url: Answerable, expectation: Expectation>) =>
    Task.where(`#actor verifies result at ${ url }`,
        Send.a(GetRequest.to(url)),
        Ensure.that(LastResponse.status(), equals(200)),
        Ensure.that(LastResponse.body(), expectation),
    );
github jan-molak / serenity-js / packages / local-server / spec / reporting.spec.ts View on Github external
it('correctly reports actor\'s activities', () => expect(theStage.theActorCalled('Nadia').attemptsTo(
            StartLocalServer.onRandomPort(),
            Ensure.that(LocalServer.url(), startsWith('http://127.0.0.1')),
            Send.a(GetRequest.to(LocalServer.url())),
            Ensure.that(LastResponse.status(), equals(200)),
            Ensure.that(LastResponse.body(), equals('Hello World!')),
            StopLocalServer.ifRunning(),
        )).to.be.fulfilled.then(() => {

            const events = (theStage.announce as sinon.SinonSpy).getCalls().map(call => call.lastArg);

            PickEvent.from(events)
                .next(ActivityStarts,   hasName(`Nadia starts the local server`))
                .next(ActivityFinished, hasName(`Nadia starts the local server`))
                .next(ActivityFinished, hasName(`Nadia ensures that the URL of the local server does start with 'http://127.0.0.1'`))
                .next(ActivityFinished, hasName(`Nadia sends a GET request to the URL of the local server`))
                .next(ActivityFinished, hasName(`Nadia ensures that the status of the last response does equal 200`))
                .next(ActivityFinished, hasName(`Nadia ensures that the body of the last response does equal 'Hello World!'`))
                .next(ActivityStarts,   hasName(`Nadia stops the local server`))
                .next(ActivityFinished, hasName(`Nadia stops the local server`))
            ;
        }));

@serenity-js/rest

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

Apache-2.0
Latest version published 1 day ago

Package Health Score

81 / 100
Full package analysis