From 6f1cf004fad42ed71d481dcbf5a0b49a9b6aadd2 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 19 Nov 2024 10:52:08 -0800 Subject: [PATCH] add expect().toBeNull() (#47716) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47716 changelog: [internal] Add toBeNull check to Fantom. Jest docs: https://jestjs.io/docs/expect#tobenull Reviewed By: javache Differential Revision: D66167811 fbshipit-source-id: 33b6cf362bcf1636f41b78dc6c84905b80be994e --- 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 217d4662b93..e33e65795d3 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(