From 50ba6e0cce2918e7846f4bb4e02312f0a39fef1b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 19 Nov 2024 09:55:16 -0800 Subject: [PATCH] add expect().toBeNull() (#47716) Summary: changelog: [internal] Add toBeNull check to Fantom. Jest docs: https://jestjs.io/docs/expect#tobenull Reviewed By: javache Differential Revision: D66167811 --- jest/integration/runtime/setup.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jest/integration/runtime/setup.js b/jest/integration/runtime/setup.js index 217d4662b9317f..e33e65795d3337 100644 --- a/jest/integration/runtime/setup.js +++ b/jest/integration/runtime/setup.js @@ -215,6 +215,15 @@ class Expect { } } + toBeNull(): void { + const pass = this.#received == null; + if (!this.#isExpectedResult(pass)) { + throw new Error( + `Expected ${String(this.#received)}${this.#maybeNotLabel()} to be null`, + ); + } + } + toThrow(expected?: string): void { if (expected != null && typeof expected !== 'string') { throw new Error(