diff --git a/jest/integration/runtime/expect.js b/jest/integration/runtime/expect.js index 98c28ba549d..5e6728950eb 100644 --- a/jest/integration/runtime/expect.js +++ b/jest/integration/runtime/expect.js @@ -165,6 +165,27 @@ class Expect { } } + toBeGreaterThan(expected: number): void { + if (typeof this.#received !== 'number') { + throw new ErrorWithCustomBlame( + `Expected ${String(this.#received)} to be a number but it was a ${typeof this.#received}`, + ).blameToPreviousFrame(); + } + + if (typeof expected !== 'number') { + throw new ErrorWithCustomBlame( + `Expected ${String(expected)} to be a number but it was a ${typeof expected}`, + ).blameToPreviousFrame(); + } + + const pass = this.#received > expected; + if (!this.#isExpectedResult(pass)) { + throw new ErrorWithCustomBlame( + `Expected ${String(this.#received)}${this.#maybeNotLabel()} to be greater than or equal to ${expected}`, + ).blameToPreviousFrame(); + } + } + toBeGreaterThanOrEqual(expected: number): void { if (typeof this.#received !== 'number') { throw new ErrorWithCustomBlame( @@ -186,6 +207,27 @@ class Expect { } } + toBeLessThan(expected: number): void { + if (typeof this.#received !== 'number') { + throw new ErrorWithCustomBlame( + `Expected ${String(this.#received)} to be a number but it was a ${typeof this.#received}`, + ).blameToPreviousFrame(); + } + + if (typeof expected !== 'number') { + throw new ErrorWithCustomBlame( + `Expected ${String(expected)} to be a number but it was a ${typeof expected}`, + ).blameToPreviousFrame(); + } + + const pass = this.#received < expected; + if (!this.#isExpectedResult(pass)) { + throw new ErrorWithCustomBlame( + `Expected ${String(this.#received)}${this.#maybeNotLabel()} to be less than or equal to ${expected}`, + ).blameToPreviousFrame(); + } + } + toBeLessThanOrEqual(expected: number): void { if (typeof this.#received !== 'number') { throw new ErrorWithCustomBlame(