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
This commit is contained in:
Samuel Susla 2024-11-19 10:52:08 -08:00 committed by Facebook GitHub Bot
parent 8fba7ebb5e
commit 6f1cf004fa

View File

@ -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(