Commit Graph
24 Commits
Author SHA1 Message Date
Rubén NorteandFacebook GitHub Bot b12ab7a3d4 Enforce that WeakRef.deref() is always called within the event loop (#50257)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50257

Changelog: [internal]

## Context

We have some tests that make sure certain objects are deallocated/released at the right times, but those are generally hard to get right. The main reason is that WeakRefs semantics are tied to the tasks and microtasks in JS, but we handle them both inside and outside the Event Loop in Fantom tests.

This leads to some surprising behavior where things we expect to have been deallocated weren't because of some innocent looking code.

## Changes

This introduces a safety mechanism in Fantom to enforce that WeakRefs are always dereferenced inside the Event Loop, by patching the method in `WeakRef` and checking if we're in the Event Loop using Fantom APIs.

It also updates the existing test using WeakRefs to fix the new errors thrown by this patch, and to serve as a "good example" on how to use WeakRefs to do memory testing.

Reviewed By: yungsters

Differential Revision: D71815397

fbshipit-source-id: 8faab1898d9112ec365b41867179abb8b251e337
2025-03-25 17:09:18 -07:00
Jack PopeandFacebook GitHub Bot 07d9cf3ed0 Back out "cleanup feature flag enableFabricCompleteRootInCommitPhase" (#49565)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49565

Original commit changeset: 6ed54f0fab45

Original Phabricator Diff: D69473992

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D69924542

fbshipit-source-id: 6438d1f6e21728de662a060893b0f08f9285be73
2025-02-21 14:26:37 -08:00
Jan KassensandFacebook GitHub Bot 14fcaf9791 cleanup feature flag enableFabricCompleteRootInCommitPhase (#49372)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49372

Changelog: [Internal]

Reviewed By: poteto

Differential Revision: D69473992

fbshipit-source-id: 6ed54f0fab45b95e47afa3ff343de061e7c40ce7
2025-02-12 13:12:07 -08:00
Andrew DatsenkoandFacebook GitHub Bot 6ec1d9d843 Add .toMatch API (#49328)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49328

Changelog: [Internal]
Add missing `.toMatch` expect API

Reviewed By: rubennorte

Differential Revision: D69462225

fbshipit-source-id: aefe02e6a1f8f15c8c30c26492fa926e7d6e4e8e
2025-02-11 11:21:33 -08:00
Andrew DatsenkoandFacebook GitHub Bot 9799e34211 Add .toHaveLength (#49327)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49327

Changelog: [Internal]
Add missing `.toHaveLength` expect API

Reviewed By: rubennorte

Differential Revision: D69241817

fbshipit-source-id: 11c7f314a30fd1db3c00b8665b613d290d50ad81
2025-02-11 10:32:27 -08:00
Andrew DatsenkoandFacebook GitHub Bot 1d5cdf10fc Add .nthCalledWith and .toHaveBeenNthCalledWith (#49221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49221

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: cortinico

Differential Revision: D69133125

fbshipit-source-id: fe4e54cbb3646c154108cee6ead9a64c3e75c1b7
2025-02-06 08:02:32 -08:00
Andrew DatsenkoandFacebook GitHub Bot 2080f64f03 Add .lastCalledWith and .toHaveBeenLastCalledWith (#49210)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49210

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69131600

fbshipit-source-id: bf7a740a4e830c5ce3403d8489bc3439428ee7b4
2025-02-05 12:52:21 -08:00
Andrew DatsenkoandFacebook GitHub Bot b30a5f8ab2 Add .toBeCalledWith and .toHaveBeenCalledWith (#49177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49177

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69123826

fbshipit-source-id: 53c550970d1cd2434f52a400ad18c8611f187176
2025-02-05 10:51:08 -08:00
Andrew DatsenkoandFacebook GitHub Bot 33ff0c4789 Update toBeCalled and toBeCalledTimes aliases (#49200)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49200

Changelog: [Internal]
Update to `toBeCalled` and `toBeCalledTimes` aliases - forward them using prototype so number of frames matches when thrown.

Reviewed By: rubennorte

Differential Revision: D69182276

fbshipit-source-id: c20469959dc2e0f5c3686c90e27cd80117ad5fb7
2025-02-05 08:26:50 -08:00
Andrew DatsenkoandFacebook GitHub Bot 87bdfda020 Add .toContain and .toContainEqual (#49178)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49178

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69130272

fbshipit-source-id: 77f45c501444700b0839a5aa7fcff807ba70641c
2025-02-05 07:43:50 -08:00
Andrew DatsenkoandFacebook GitHub Bot b0501a5be2 Add .toStrictEqual (#49176)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49176

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69123117

fbshipit-source-id: 11c326f7ac4df80852409a1c9d72c911ceff21f7
2025-02-04 13:52:57 -08:00
Andrew DatsenkoandFacebook GitHub Bot a702238bed Add .toBeFalsy and .toBeTruthy (#49169)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49169

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69119852

fbshipit-source-id: dfda47dcc61f17ecbd205863d83b268005c74a83
2025-02-04 10:54:19 -08:00
Andrew DatsenkoandFacebook GitHub Bot e0f514d860 Add .toBeDefined and .toBeUndefined (#49168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49168

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69119330

fbshipit-source-id: 2da7643cd969587b3aabe17d8c9eb405bc814b7b
2025-02-04 09:11:00 -08:00
Andrew DatsenkoandFacebook GitHub Bot 13b57781ba Add .toBeCalled and .toBeCalledTimes (#49165)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49165

Changelog: [Internal]
Add missing jest expect apis

Reviewed By: rubennorte

Differential Revision: D69118825

fbshipit-source-id: bed276d8ba544b2351157052c3b37ebcc7398129
2025-02-04 08:26:06 -08:00
Rubén NorteandFacebook GitHub Bot 7e12060420 Move Fantom-related specs to src/private/testing/fantom/specs (#49101)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49101

Changelog: [internal]

We can move this out of the deprecated directory. Also added a `.npmignore` entry so this won't be published to npm with the package.

Reviewed By: lenaic

Differential Revision: D68896208

fbshipit-source-id: ec85236aeeabdc9abcd870f0f4c1322eeb3cc659
2025-02-03 09:15:31 -08:00
Rubén NorteandFacebook GitHub Bot 2f27327f33 Rename src/private/specs as src/private/specs_DEPRECATED (#49068)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49068

Changelog: [internal]

Renamed directory to better signal it's deprecated and added README.md to clarify intent.

Reviewed By: huntie

Differential Revision: D68895998

fbshipit-source-id: 5bc70d0782194db27c27cc89cc402d99f11aafa4
2025-02-03 09:15:31 -08:00
Pieter De BaetsandFacebook GitHub Bot 26afc804b7 Error when tests finish with pending tasks (#49032)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49032

Add a native API to validate the RuntimeScheduler has no pending tasks, and automatically validate after every test that there's no pending tasks left to execute.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D68797481

fbshipit-source-id: dbbef894a57bd29eb5a033ac8aaeedef770dcba2
2025-01-29 08:49:49 -08:00
Andrew DatsenkoandFacebook GitHub Bot cf6b807745 Add support for (before|after)(Each|All) methods (#48820)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48820

Changelog: [Internal]
Add capability to setup / teardown tests

Reviewed By: rubennorte

Differential Revision: D68454176

fbshipit-source-id: 93c19c91dfe2b8b98385547da24955fd31adbf0b
2025-01-23 09:45:21 -08:00
Rubén NorteandFacebook GitHub Bot 726a72328e Use structured output for Fantom logs and test results (#48369)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48369

Changelog: [internal]

This improves logs in Fantom by preserving the original log levels. It's also in preparation for adding support for log streaming in tests.

Reviewed By: javache

Differential Revision: D67600616

fbshipit-source-id: 1c4997d5e836a78327f33092527543fe025c90c6
2025-01-03 04:57:43 -08:00
Rubén NorteandFacebook GitHub Bot f20486cc77 Improve error messages in expect().toThrow(message) (#48430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48430

Changelog: [internal]

This expectation currently prints a very generic message that is hard to parse, so this change improves it a bit to account for more cases. E.g.:
* Before: "Expected <function> to throw"
* After: "Expected <function> to throw with message 'foo', but threw with message 'bar'"

Reviewed By: rshest

Differential Revision: D67738146

fbshipit-source-id: 690f15971cec0e8a7b038eeacc9302c9f3edc323
2025-01-03 02:16:38 -08:00
Rubén NorteandFacebook GitHub Bot 06584241ba Fix ESLint warnings and remove from ignore list (#48291)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48291

Changelog: [internal]

`react-native-fantom` was added to `.eslintignore` when we upgraded to React 19 because we wanted to reduce the amount of warnings to ease the migration.

This re-enables ESLint for that directory and removes the warnings.

Reviewed By: cipolleschi

Differential Revision: D67283104

fbshipit-source-id: 4ec2363ceaff3cd7bd6e5d70e9588c3dd22d7d85
2024-12-16 09:19:55 -08:00
Andrew DatsenkoandFacebook GitHub Bot a298ccabe2 Add snapshot update / delete capability (#48096)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48096

Changelog: [Internal]

Managing snapshot state internally by adding / updating snapshot data.

Reviewed By: christophpurrer

Differential Revision: D66707175

fbshipit-source-id: 0366d834eafa0ca702f03de0210392181fd90a58
2024-12-09 19:09:57 -08:00
Andrew DatsenkoandFacebook GitHub Bot a8a136f3ef Add .toMatchSnapshot() (#48029)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48029

Changelog: [Internal]

Adding snapshot support for rendered output only for now.
This will only work if snapshot is created beforehand by hand.

# Next steps
* Create snapshot when no prior snapshot is available
* Pass and update if instructed

Reviewed By: christophpurrer

Differential Revision: D66601387

fbshipit-source-id: fe528cded43c5ba36d314bd9af8e3fb84b98ac3e
2024-12-09 19:09:57 -08:00
Rubén NorteandFacebook GitHub Bot 81fbd18410 Move remaining Fantom files to react-native-fantom (#48143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48143

Changelog: [internal]

Just a small cleanup to move `jest/integration/*` to `packages/react-native-fantom`, so everything related to Fantom (config, runner, runtime, etc.) is in the same directory.

Reviewed By: javache

Differential Revision: D66874763

fbshipit-source-id: 8b87d7320c7704f7ce6cd58761508193784f5ce2
2024-12-06 05:24:31 -08:00