How to use the @serenity-js/core.AssertionError 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 / jasmine / src / SerenityReporterForJasmine.ts View on Github external
private failureOutcomeFrom(failure: Expectation): ProblemIndication {
        const error = this.errorFrom(failure);

        if (error instanceof AssertionError) {
            // sadly, Jasmine error propagation mechanism is rather basic
            // and unable to serialise the expected/actual properties of the AssertionError object
            return new ExecutionFailedWithAssertionError(error);
        }

        if (!! failure.matcherName) {                       // the presence of a non-empty matcherName property indicates a Jasmine-specific assertion error
            return new ExecutionFailedWithAssertionError(
                new AssertionError(failure.message, failure.expected, failure.actual, error),
            );
        }

        return new ExecutionFailedWithError(error);
    }
github jan-molak / serenity-js / integration / cucumber-2-runner / src / step_definitions / synchronous.steps.ts View on Github external
Given(/^.*step (?:.*) fails with assertion error$/, function () {
        throw new AssertionError(`Expected false to equal true`, false, true);
    });
github jan-molak / serenity-js / integration / cucumber-5-runner / src / step_definitions / promise.steps.ts View on Github external
Given(/^.*step (?:.*) fails with assertion error$/, function () {
    return Promise.reject(new AssertionError(`Expected false to equal true`, false, true));
});
github jan-molak / serenity-js / integration / cucumber-5-runner / src / step_definitions / callback.steps.ts View on Github external
Given(/^.*step (?:.*) fails with assertion error$/, function (done: Callback) {
    done(new AssertionError(`Expected false to equal true`, false, true));
});
github jan-molak / serenity-js / integration / cucumber-5-runner / src / step_definitions / synchronous.steps.ts View on Github external
Given(/^.*step (?:.*) fails with assertion error$/, function () {
    throw new AssertionError(`Expected false to equal true`, false, true);
});
github jan-molak / serenity-js / integration / cucumber-1-runner / src / step_definitions / promise.steps.ts View on Github external
this.Given(/^.*step (?:.*) fails with assertion error$/, function () {
        return Promise.reject(new AssertionError(`Expected false to equal true`, false, true));
    });
github jan-molak / serenity-js / packages / assertions / src / assertions / not.ts View on Github external
() => {
                        throw new AssertionError(
                            `Expected ${ formatted `${ actual }` } to not ${ this.assertion.toString() }`,
                            void 0,
                            actual,
                        );
                    },
                    error => {
github jan-molak / serenity-js / packages / protractor / src / screenplay / interactions / Wait.ts View on Github external
.catch(error => {
                if (!! expectationOutcome) {
                    throw new AssertionError(
                        `Waited ${ this.timeout.toString() } for ${ formatted `${ this.actual }` } to ${ this.expectation.toString() }`,
                        expectationOutcome.expected,
                        expectationOutcome.actual,
                        error,
                    );
                }

                throw error;
            });
    }