How to use the @serenity-js/assertions.equals 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 / protractor / spec / screenplay / questions / LastScriptExecution.spec.ts View on Github external
it('returns null if the script did not return any result', () => Joe.attemptsTo(
            Navigate.to(page),

            ExecuteScript.sync(`
                /* do nothing */
            `),

            Ensure.that(LastScriptExecution.result(), equals(null)),
        ));
    });
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 / Cookie.spec.ts View on Github external
it('returns an undefined when it can\'t retrieve it', () => Sid.attemptsTo(
                Navigate.to(cookieCutterURLFor('/cookie?name=favourite&value=chocolate-chip')),
                Ensure.that(Cookie.pathOf('not-so-favourite'), equals(undefined)),
            ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / interactions / Wait.spec.ts View on Github external
it('fails the actor flow when the timeout expires', () => expect(Bernie.attemptsTo(
            Navigate.to(Test_Page),

            Wait.upTo(Duration.ofMilliseconds(10)).until(Text.of(Status), equals('Ready!')),
        )).to.be.rejected.then((error: AssertionError) => {
            expect(error).to.be.instanceOf(AssertionError);
            expect(error.message).to.be.equal(`Waited 10ms for the text of the header to equal 'Ready!'`);
            expect(error.actual).to.be.equal('Loading...');
            expect(error.expected).to.be.equal('Ready!');

            expect(error.cause.name).to.equal('TimeoutError');
            expect(error.cause.message).to.match(/^Wait timed out after.*/);
        }));
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`))
            ;
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Target.spec.ts View on Github external
it('a single web element matching the selector', () => Bernie.attemptsTo(
            Navigate.to(shoppingListPage),

            Ensure.that(Text.of(ShoppingList.Header), equals('Shopping list')),
        ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / interactions / Wait.spec.ts View on Github external
it('pauses the actor flow until the expectation is met', () => Bernie.attemptsTo(
            Navigate.to(Test_Page),

            Wait.until(Text.of(Status), equals('Ready!')),

            Ensure.that(Text.of(Status), equals('Ready!')),
        ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Pick.spec.ts View on Github external
it('gets the number of items', () => Peter.attemptsTo(
                Navigate.to(shoppingListPage),

                Ensure.that(picked.count(), equals(1)),
            ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / interactions / Wait.spec.ts View on Github external
it('pauses the actor flow for the length of an explicitly-set duration', () => Bernie.attemptsTo(
            Navigate.to(Test_Page),

            Wait.for(Duration.ofMilliseconds(300)),

            Ensure.that(Text.of(Status), equals('Ready!')),
        ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Cookie.spec.ts View on Github external
it('allows the actor to retrieve it', () => Sid.attemptsTo(
                Navigate.to(cookieCutterURLFor('/cookie?name=favourite&value=chocolate-chip')),
                Ensure.that(Cookie.valueOf('favourite'), equals('chocolate-chip')),
            ));