How to use the @serenity-js/core/lib/domain.Result.FAILURE function in @serenity-js/core

To help you get started, we’ve selected a few @serenity-js/core 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 / serenity-js / spec / api / serenity-protractor / framework / protractor_reporter.spec.ts View on Github external
scene_2 = new RecordedScene(
                      scenario_2,
                      feature,
                      { path: featureFile },
                  ),
                  scene_2_duration = 7,
                  logsIn = new RecordedActivity('Logs in'),
                  logsIn_duration = 10,
                  entersUsername = new RecordedActivity('Enters username'),
                  entersUsername_duration = 6,
                  entersPassword = new RecordedActivity('Enters password'),
                  entersPassword_duration = 4,
                  selectsAProduct = new RecordedActivity('Selects a product');

            const examplesOfSuccess = [ Result.SUCCESS, Result.PENDING, Result.IGNORED, Result.SKIPPED ],
                  examplesOfFailure    = [ Result.FAILURE, Result.COMPROMISED, Result.ERROR ];

            let protractor: Runner,
                reporter: ProtractorReporter,
                stage: Stage;

            beforeEach(() => {
                stage      = new Stage(new StageManager(new Journal()));
                protractor = sinon.createStubInstance(Runner) as any;

                reporter   = new ProtractorReporter(protractor);
                reporter.assignTo(stage);
            });

            describe('complies with the Protractor Framework specification:', () => {

                // Protractor Framework spec:
github jan-molak / serenity-js / packages / serenity-js / spec / api / serenity-protractor / stage / photographer.spec.ts View on Github external
it('finished with a Failure', () => {

                        const failure = new Error('Expected the list of items to contain 5 items but it only had 4');

                        fileSystem.store.withArgs(photoName, imageBuffer).returns(photoPath);

                        thePhotographer.notifyOf(new ActivityFinished(new Outcome(activity, Result.FAILURE, failure), now));

                        const photoAttempted = stageManager.readTheJournal().pop();

                        expect(photoAttempted).to.be.instanceOf(PhotoAttempted);
                        expect(photoAttempted.timestamp).to.equal(now);

                        expect(photoAttempted.value).to.be.instanceOf(PhotoReceipt);
                        expect(photoAttempted.value.activity).to.deep.equal(activity);
                        return expect(photoAttempted.value.photo).to.eventually.deep.equal(new Photo(photoPath));
                    });
github jan-molak / serenity-js / packages / cucumber-2 / src / notifier.ts View on Github external
static from = (result: StepResult | ScenarioResult) => {
        const isTimeOut = (e: Error) => e && /timed out/.test(e.message);

        const results = {
            undefined: Result.PENDING,
            failed: Result.FAILURE,
            pending: Result.PENDING,
            passed: Result.SUCCESS,
            skipped: Result.SKIPPED,
        };

        if (!results[ result.status ]) {
            throw new Error(`Couldn't map the '${ result.status }' to a Serenity Result`);
        }

        return isTimeOut(realErrorFrom(result.failureException))
            ? Result.ERROR
            : results[ result.status ];
    }
}
github jan-molak / serenity-js / packages / cucumber / src / transformations.ts View on Github external
function serenityResultFrom(stepStatus: string, error?: Error): Result {
    const timeOut = (e: Error) => e && /timed out/.test(e.message);

    const results = {
        undefined: Result.PENDING,
        ambiguous: Result.ERROR,
        failed:    Result.FAILURE,
        pending:   Result.PENDING,
        passed:    Result.SUCCESS,
        skipped:   Result.SKIPPED,
    };

    if (! results[stepStatus]) {
        throw new Error(`Couldn't map '${ stepStatus }' to a Serenity Result`);
    }

    return timeOut(error)
        ? Result.ERROR
        : results[stepStatus];
}
github jan-molak / serenity-js / packages / serenity-js / src / serenity-mocha / model.ts View on Github external
function finalStateOf(scenario: ExecutedScenario): Result {

    if (scenario.pending) {
        return Result.PENDING;
    }

    if (scenario.state === 'passed') {
        return Result.SUCCESS;
    }

    if (timedOut(scenario) || hasErrors(scenario)) {
        return Result.ERROR;
    }

    if (scenario.state === 'failed') {
        return Result.FAILURE;
    }

    return Result.COMPROMISED;
}
github jan-molak / serenity-js / packages / mocha / spec / recognises_scenario_results.spec.ts View on Github external
return expect(spawned.result).to.be.eventually.rejected.then(() => {
                expect(spawned.messages).to.have.lengthOf(2);

                const event = lastOf(SceneFinished, spawned.messages);

                expect(Result[event.value.result]).to.equal(Result[Result.FAILURE]);
                expect(event.value.error).to.deep.equal({
                    actual: 'async pass',
                    expected: 'async fail',
                    message: 'expected \'async pass\' to equal \'async fail\'',
                    name: 'AssertionError',
                    showDiff: true,
                });
            });
        });
github jan-molak / serenity-js / packages / serenity-js / spec / integration / mocha / recognises_scenario_results.ts View on Github external
return expect(spawned.result).to.be.eventually.rejected.then(() => {
                expect(spawned.messages).to.have.length.greaterThan(2);

                const event = lastOf(SceneFinished, spawned.messages);

                expect(Result[event.value.result]).to.equal(Result[Result.FAILURE]);
            });
        });
github jan-molak / serenity-js / packages / serenity-js / spec / integration / mocha / recognises_scenario_results.ts View on Github external
return expect(spawned.result).to.be.eventually.rejected.then(() => {
                expect(spawned.messages).to.have.length.greaterThan(2);

                const event = lastOf(SceneFinished, spawned.messages);

                expect(Result[event.value.result]).to.equal(Result[Result.FAILURE]);
                expect(event.value.error).to.deep.equal({
                    actual: 'async pass',
                    expected: 'async fail',
                    message: 'expected \'async pass\' to equal \'async fail\'',
                    name: 'AssertionError',
                    showDiff: true,
                });
            });
        });
github jan-molak / serenity-js / packages / cucumber-2 / spec / cucumber_adapter.spec.ts View on Github external
return expect(spawned.result).to.be.eventually.rejected.then(() => {
                expect(spawned.messages).to.have.lengthOf(4);

                expect(spawned.messages).to.have.lengthOf(4);

                expect(spawned.messages[0].value.name).to.equal(scenario);
                expect(spawned.messages[1].value.name).to.equal(step);
                expect(spawned.messages[2].value.subject.name).to.equal(step);
                expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.FAILURE]);
                expect(spawned.messages[3].value.subject.name).to.equal(scenario);
                expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.FAILURE]);
            });
        });
github jan-molak / serenity-js / packages / cucumber-2 / spec / cucumber_adapter.spec.ts View on Github external
return expect(spawned.result).to.be.eventually.rejected.then(() => {
                expect(spawned.messages).to.have.lengthOf(4);

                expect(spawned.messages).to.have.lengthOf(4);

                expect(spawned.messages[0].value.name).to.equal(scenario);
                expect(spawned.messages[1].value.name).to.equal(step);
                expect(spawned.messages[2].value.subject.name).to.equal(step);
                expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.FAILURE]);
                expect(spawned.messages[3].value.subject.name).to.equal(scenario);
                expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.FAILURE]);
            });
        });