How to use the @serenity-js/core/lib/domain.Result.ERROR 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 / 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-cucumber / cucumber_serenity_notifier.ts View on Github external
const timeOut = (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[stepStatus]) {
        throw new Error(`Couldn't map the '${ 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 / 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.ERROR]);
                expect(event.value.error.message).to.match(/Timeout of 5ms exceeded./);
            });
        });
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.ERROR]);
                expect(event.value.error.message).to.match(/Timeout of 5ms exceeded./);
            });
        });
github jan-molak / serenity-js / packages / cucumber / src / transformations.ts View on Github external
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];
}