Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
Given(/^.*step (?:.*) fails with assertion error$/, function () {
throw new AssertionError(`Expected false to equal true`, false, true);
});
Given(/^.*step (?:.*) fails with assertion error$/, function () {
return Promise.reject(new AssertionError(`Expected false to equal true`, false, true));
});
Given(/^.*step (?:.*) fails with assertion error$/, function (done: Callback) {
done(new AssertionError(`Expected false to equal true`, false, true));
});
Given(/^.*step (?:.*) fails with assertion error$/, function () {
throw new AssertionError(`Expected false to equal true`, false, true);
});
this.Given(/^.*step (?:.*) fails with assertion error$/, function () {
return Promise.reject(new AssertionError(`Expected false to equal true`, false, true));
});
() => {
throw new AssertionError(
`Expected ${ formatted `${ actual }` } to not ${ this.assertion.toString() }`,
void 0,
actual,
);
},
error => {
.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;
});
}