How to use the @serenity-js/core/lib/model.ExecutionSuccessful 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 / cucumber / src / listeners / cucumber-0.ts View on Github external
}

            return new ExecutionFailedWithError(error);

        case status === 'failed':
            switch (true) {
                case error instanceof AssertionError:       return new ExecutionFailedWithAssertionError(error as AssertionError);
                case error instanceof TestCompromisedError: return new ExecutionCompromised(error as TestCompromisedError);
                default:                                    return new ExecutionFailedWithError(error);
            }

        case status === 'pending':
            return new ImplementationPending(new ImplementationPendingError('Step not implemented'));

        case status === 'passed':
            return new ExecutionSuccessful();

        case status === 'skipped':
            return new ExecutionSkipped();
    }
    // tslint:enable:switch-default
}
github jan-molak / serenity-js / packages / serenity-bdd / spec / stage / crew / serenity-bdd-reporter / SerenityBDDReporter / tagging_scenarios.spec.ts View on Github external
it('belongs to a theme', () => {
                    given(reporter).isNotifiedOfFollowingEvents(
                        new SceneTagged(defaultCardScenario, new ThemeTag('Digital')),
                        new SceneTagged(defaultCardScenario, new CapabilityTag('E-Commerce')),
                        new SceneTagged(defaultCardScenario, new FeatureTag('Checkout')),
                        new SceneFinished(defaultCardScenario, new ExecutionSuccessful()),
                        new TestRunFinished(),
                    );

                    report = stageManager.notifyOf.firstCall.lastArg.artifact.map(_ => _);

                    expect(report.tags).to.deep.include.members([{
                        name: 'Digital',
                        type: 'theme',
                    }, {
                        name: 'Digital/E-Commerce',
                        type: 'capability',
                    }, {
                        name: 'Digital/E-Commerce/Checkout',
                        type: 'feature',
                    }]);
github jan-molak / serenity-js / packages / serenity-bdd / spec / stage / crew / serenity-bdd-reporter / SerenityBDDReporter / reporting_activities.spec.ts View on Github external
it('records the order of test steps so that the Serenity BDD reporter can display the reportData in the correct context', () => {
            const
                pickACard   = new ActivityDetails(new Name('Pick a credit card')),
                makePayment = new ActivityDetails(new Name('Make a payment'));

            given(reporter).isNotifiedOfFollowingEvents(
                new SceneStarts(defaultCardScenario),
                    new TaskStarts(pickACard),
                        new ArtifactGenerated(new Name('pick a card message'), JSONData.fromJSON({ card: 'default' })),
                        new ArtifactArchived(new Name('pick a card message'), JSONData, new Path('target/site/serenity/pick-a-card-message-md5hash.json')),
                    new TaskFinished(pickACard, new ExecutionSuccessful()),
                    new TaskStarts(makePayment),
                        new ArtifactGenerated(new Name('make a payment message'), JSONData.fromJSON({ amount: '£42' })),
                        new ArtifactArchived(new Name('make a payment message'), JSONData, new Path('target/site/serenity/make-a-payment-message-md5hash.json')),
                        new ArtifactGenerated(new Name('server log'), TextData.fromJSON({ contentType: 'text/plain', data: 'received payment request' })),
                    new TaskFinished(makePayment, new ExecutionSuccessful()),
                new SceneFinished(defaultCardScenario, new ExecutionSuccessful()),
                new TestRunFinished(),
            );

            const report: SerenityBDDReport = stageManager.notifyOf.firstCall.lastArg.artifact.map(_ => _);

            expect(report.testSteps).to.have.lengthOf(2);
            expect(report.testSteps[0].number).to.equal(1);
            expect(report.testSteps[0].reportData[0].title).to.equal('pick a card message');
            expect(report.testSteps[0].reportData[0].contents).to.equal('{\n    "card": "default"\n}');

            expect(report.testSteps[1].number).to.equal(2);

            expect(report.testSteps[1].reportData[0].title).to.equal('make a payment message');
            expect(report.testSteps[1].reportData[0].contents).to.deep.equal('{\n    \"amount\": \"£42\"\n}');
github jan-molak / serenity-js / packages / serenity-bdd / spec / stage / crew / serenity-bdd-reporter / SerenityBDDReporter / reporting_scene_sequences.spec.ts View on Github external
it('captures information about a sequence of scenes (2 scenes in a sequence)', () => {
        given(reporter).isNotifiedOfFollowingEvents(
            new SceneSequenceDetected(sequence),
                new SceneTemplateDetected(template),
                new SceneParametersDetected(
                    scenario1,
                    new ScenarioParameters(
                        new Name('Serenity/JS contributors'),
                        new Description(`Some of the people who have contributed their time and talent to the Serenity/JS project`),
                        { Developer: 'jan-molak', Twitter_Handle: '@JanMolak' },
                    ),
                ),
                new SceneStarts(scenario1),
                new SceneFinished(scenario1, new ExecutionSuccessful()),
            new SceneSequenceDetected(sequence),
                new SceneTemplateDetected(template),
                new SceneParametersDetected(
                    scenario2,
                    new ScenarioParameters(
                        new Name('Serenity/JS contributors'),
                        new Description(`Some of the people who have contributed their time and talent to the Serenity/JS project`),
                        { Developer: 'wakaleo', Twitter_Handle: '@wakaleo' },
                    ),
                ),
                new SceneStarts(scenario2),
                new SceneFinished(scenario2, new ExecutionSuccessful()),
            new TestRunFinished(),
        );

        const report: SerenityBDDReport = stageManager.notifyOf.firstCall.lastArg.artifact.map(_ => _);
github jan-molak / serenity-js / packages / serenity-bdd / spec / stage / crew / serenity-bdd-reporter / SerenityBDDReporter / reporting_activities.spec.ts View on Github external
it('reports the outcome of a single activity', () => {
            const pickACard = new ActivityDetails(new Name('Pick the default credit card'));

            given(reporter).isNotifiedOfFollowingEvents(
                new SceneStarts(defaultCardScenario),
                    new TaskStarts(pickACard),
                    new TaskFinished(pickACard, new ExecutionSuccessful()),
                new SceneFinished(defaultCardScenario, new ExecutionSuccessful()),
                new TestRunFinished(),
            );

            const report: SerenityBDDReport = stageManager.notifyOf.firstCall.lastArg.artifact.map(_ => _);

            expect(report.testSteps).to.have.lengthOf(1);
            expect(report.testSteps[0].description).to.equal(pickACard.name.value);
            expect(report.testSteps[0].result).to.equal('SUCCESS');
        });
github jan-molak / serenity-js / packages / jasmine / src / SerenityReporterForJasmine.ts View on Github external
private outcomeFrom(result: SpecResult | SuiteResult): Outcome {
        switch (result.status) {
            case 'failed':
                return this.failureOutcomeFrom(result.failedExpectations[0]);
            case 'pending':
                return new ImplementationPending(new ImplementationPendingError((result as any).pendingReason || ''));
            case 'excluded':
                return new ExecutionSkipped();
            case 'passed':
            default:
                return new ExecutionSuccessful();
        }
    }
github jan-molak / serenity-js / integration / cucumber / spec / screenplay_scenario.spec.ts View on Github external
                .next(SceneFinished,       event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
            ;
github jan-molak / serenity-js / packages / serenity-bdd / src / stage / crew / serenity-bdd-reporter / reports / SceneReport.ts View on Github external
if (this.parameters.length > 0) {
                const entry = this.parameters.find(p => p.line === scenario.location.line);
                if (!! entry) {
                    entry.outcome = outcome;

                    report.dataTable.rows[ entry.index ].result = result;

                    const worstOutcomeOverall = this.parameters
                        .filter(p => !! p.outcome)
                        .map(p => p.outcome)
                        .reduce((worstSoFar, current) => {
                            return current.isWorseThan(worstSoFar)
                                ? current
                                : worstSoFar;
                        }, new ExecutionSuccessful());

                    this.mapOutcome(worstOutcomeOverall, (r: string, e: ErrorDetails = undefined) => {
                        report.result           = r;
                        report.testFailureCause = e;
                    });
                }
            }
        }));
    }
github jan-molak / serenity-js / packages / protractor / spec / adapter / ProtractorFrameworkAdapter.spec.ts View on Github external
function sample(type: 'passing.spec.ts' | 'failing.spec.ts' | string) {
        return type === 'passing.spec.ts'
            ? { path: 'passing.spec.ts', name: 'passing test', category: 'samples', description: 'samples passing test', outcome: new ExecutionSuccessful() }
            : { path: 'failing.spec.ts', name: 'failing test', category: 'samples', description: 'samples failing test', outcome: new ExecutionFailedWithError(expectedError) };
    }