How to use the @serenity-js/assertions.startsWith function in @serenity-js/assertions

To help you get started, we’ve selected a few @serenity-js/assertions 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
}

            class Actors implements DressingRoom {
                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 / RequestCalculationOf.ts View on Github external
export const RequestCalculationOf = (expression: string) =>
    Task.where(`#actor requests calculation of ${ expression }`,
        Send.a(
            PostRequest.to('/api/calculations').with(expression).using({ headers: { 'Content-Type': 'text/plain' }}),
        ),
        Ensure.that(LastResponse.status(), equals(201)),
        Ensure.that(LastResponse.header('location'), startsWith('/api/calculations/')),
    );
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Pick.spec.ts View on Github external
it('picks the first item', () => Peter.attemptsTo(
                Navigate.to(shoppingListPage),

                Ensure.that(Text.of(picked.first()), startsWith('oats')),
            ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Pick.spec.ts View on Github external
describe('(when multiple filters are applied)', () => {

        const picked = Pick.from(ShoppingList.Items).where(CSSClasses, contain('buy')).where(Text, startsWith('coconut'));

        describe('lets the actor filter the list of matching elements so that it', () => {

            it('gets the number of items', () => Peter.attemptsTo(
                Navigate.to(shoppingListPage),

                Ensure.that(picked.count(), equals(1)),
            ));

            it('picks all the items', () => Peter.attemptsTo(
                Navigate.to(shoppingListPage),

                Ensure.that(Text.ofAll(picked.all()), contain('coconut milk x')),
            ));

            it('picks the first item', () => Peter.attemptsTo(
github jan-molak / serenity-js / packages / local-server / spec / servers.spec.ts View on Github external
describe('when working with HTTPS', () => {

        const testHttpsServer = [
            StartLocalServer.onOneOfThePreferredPorts([ 8443, 9443 ]),
            Ensure.that(LocalServer.url(), startsWith('https://127.0.0.1')),
            Send.a(GetRequest.to(LocalServer.url())),
            Ensure.that(LastResponse.status(), equals(200)),
            Ensure.that(LastResponse.body(), equals('Hello World!')),
        ];

        given(
            require('./servers/barebones'),
            require('./servers/express'),
            require('./servers/koa'),
        ).
        it('allows the Actor to start, stop and access the location of a HTTPS', function ({ handler, node }) {
            if (! satisfies(process.versions.node, node)) {
                return this.skip();
            }

            class Actors implements DressingRoom {
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Pick.spec.ts View on Github external
it('picks the nth item', () => Peter.attemptsTo(
                Navigate.to(shoppingListPage),

                Ensure.that(Text.of(picked.get(1)), startsWith('coconut milk')),
            ));
        });
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`))