How to use the @serenity-js/assertions.includes 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 / interactions / execute-script / ExecuteSynchronousScript.spec.ts View on Github external
it('emits the events so that the details of the script being executed can be reported', () => {
        const
            frozenClock = new Clock(() => new Date('1970-01-01')),

            theStage = stage(new UIActors(), frozenClock),
            actor = theStage.theActorCalled('Ashwin');

        sinon.spy(theStage, 'announce');

        return actor.attemptsTo(
            ExecuteScript.sync(`console.log('hello world');`),
            Ensure.that(Browser.log(), containAtLeastOneItemThat(property('message', includes('hello world')))),
        ).then(() => {
            const events = (theStage.announce as sinon.SinonSpy).getCalls().map(call => call.lastArg);

            expect(events).to.have.lengthOf(5);
            expect(events[ 0 ]).to.be.instanceOf(ActivityStarts);
            expect(events[ 1 ]).to.be.instanceOf(ArtifactGenerated);
            expect(events[ 2 ]).to.be.instanceOf(ActivityFinished);

            const artifactGenerated = events[ 1 ] as ActivityRelatedArtifactGenerated;

            expect(artifactGenerated.name.value).to.equal(`Script source`);

            expect(artifactGenerated.artifact.equals(TextData.fromJSON({
                contentType: 'text/javascript;charset=UTF-8',
                data: 'console.log(\'hello world\');',
            }))).to.equal(true, JSON.stringify(artifactGenerated.artifact.toJSON()));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / questions / Browser.spec.ts View on Github external
it('allows the actor to read the browser log entries', () => Bernie.attemptsTo(
        Navigate.to(pageFromTemplate(`
            
                
                    
                
            
        `)),

        Ensure.that(Browser.log(), containAtLeastOneItemThat(property('message', includes('Hello from the console!')))),
    ));
github jan-molak / serenity-js / packages / protractor / spec / screenplay / interactions / execute-script / ExecuteScriptFromUrl.spec.ts View on Github external
.then(() => Joe.attemptsTo(
            Ensure.that(Browser.log(), containAtLeastOneItemThat(property('message', includes('execute-script-sample.js.invalid - Failed to load resource')))),
        )));