BettererTestConstraint
API > @betterer/betterer > BettererTestConstraint
A function that checks if a test result is better
, worse
, or the same
than the expected result.
Signature
export declare type BettererTestConstraint<DeserialisedType> = (result: DeserialisedType, expected: DeserialisedType) => MaybeAsync<BettererConstraintResult>;
References
Example
import { BettererConstraintResult } from '@betterer/constraints';
export function bigger(result: number, expected: number): BettererConstraintResult {
if (result === expected) {
return BettererConstraintResult.same;
}
if (result > expected) {
return BettererConstraintResult.better;
}
return BettererConstraintResult.worse;
}