Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52473
Shared utils that were located in the root of `scripts/` are now colocated closer to their dependencies or moved to `scripts/shared/` — simplifying the root directory layout.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D77873875
fbshipit-source-id: e04dba41a1ef811d32793931033fdfa93afad0cd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51858
Creates a new private package for the ESLint rules that are defined in the `facebook/react-native` repository for linting the monorepo itself: `react-native/eslint-plugin-monorepo`
It resides in a new `private/` directory that will be used for all private packages. I plan to move private packages over from `packages/` and `tools/`.
This also eliminates the need for the `eslint-plugin-lint` dependency in open source.
Changelog:
[Internal]
Reviewed By: cortinico
Differential Revision: D76088698
fbshipit-source-id: 697d5d91421cda4ef3f96d0497a96954cd047296
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49102
Moves this script one level up. In the next diff, will be used to support execution of scripts themselves, as well as `packages/`.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D68960279
fbshipit-source-id: 7b62420c269dc1c1366ac9a827db078d34cb86c5
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
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48142
Changelog: [internal]
This is the default export from the `react-native/fantom` package and it makes sense to be called that way. Also, this is similar to the `jest` global.
Reviewed By: javache
Differential Revision: D66874225
fbshipit-source-id: 8b43a637ebb42b5b1acb9ea5a6dbedd4c1a4f9e0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48125
Changelog: [internal]
This just moves the runtime modules for Fantom to its own package.
Reviewed By: javache
Differential Revision: D66825478
fbshipit-source-id: ac4dbc23b86895f09abc46345d497c1c53737ae2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48097
Changelog: [internal]
As per title, this allows us to specify both common and JS-only feature flags for tests in the docblock as pragmas (in the same pragma separated by spaces, or in different pragmas). E.g.:
```
/**
* fantom_flags commonTestFlag:true
* fantom_flags jsOnlyTestFlag:true
*/
```
The feature flags are overridden automatically for us before the tests start.
Reviewed By: javache
Differential Revision: D66760121
fbshipit-source-id: 7e227e0035a170dab81b1e6ce39600a01a748867
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48092
Changelog: [internal]
This is just in preparation to expand the scope of that function to include configuration for feature flags.
Reviewed By: javache
Differential Revision: D66760119
fbshipit-source-id: e955e8f596697ac6a0a87013bec3fc3e09caf19d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48086
Changelog: [internal]
Just adding a bit of coverage for the `expect` API adding `toBeLessThan` and `toBeGreaterThan`.
Reviewed By: sammy-SC
Differential Revision: D66753268
fbshipit-source-id: 6a26f558f985ccbb5eb0daacecd93759841149e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48083
Changelog: [internal]
Just a small refactor to have a better code organization for the testing runtime infra.
Reviewed By: sammy-SC
Differential Revision: D66753269
fbshipit-source-id: e68727fe45fabe0be3528e21d5a60cef3045c252
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48048
Changelog: [Internal]
Some messages may contains multi line content, ie snapshot comparison, multiline strings comparison.
Fixing this by checking first code pointer in the stack and slicing from there.
Reviewed By: christophpurrer, rubennorte
Differential Revision: D66660107
fbshipit-source-id: 57cea02cf6aae3c24f351504c2e077b5a2de0761
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48022
Changelog: [internal]
This adds support for Fantom options in tests to configure different aspects of the test execution.
For now, it only supports specifying the mode (dev or opt) so we can try things without having to change the runner (watch mode still works if you change mode :D).
Fantom options are specified as pragmas in the docblock of the test. E.g.:
```
/**
* flow strict-local
* format
* fantom_mode opt
*/
```
We expect this is mostly going to be used for one-time tests and that regular tests won't specify the mode (they'll just run in dev mode).
Maybe we can evolve this in the future to specify that you want a test to be executed in both modes, to ensure the behavior is consistent in dev/prod.
Reviewed By: rshest
Differential Revision: D66597626
fbshipit-source-id: b12325fc2235740cc2a3e0283d6a556091c1794c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48015
Changelog: [internal]
Right now, when we run individual Fantom tests, we compile Hermes and the RN Tester CLI as part of the test, which causes the first test to run to be very slow and the remaining tests in the same run to be very fast.
This is misleading because it makes it look like the test itself is slow, when it's actually paying a price for everyone.
Fortunately, Jest has an option to do a global setup before any tests in the project run (and it doesn't run if none of the tests in the project run, in multi-project setups), so we can use it to do the necessary warmup so it doesn't end up being attributed to individual tests.
Reviewed By: javache
Differential Revision: D66595406
fbshipit-source-id: 496aa2b248da661f7504c8445fed1edad0301803
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48014
Changelog: [internal]
Just a small refactor in preparation for a following change that will add more usages for these utilities. It also cleans up the runner file which is good too.
Reviewed By: javache
Differential Revision: D66595405
fbshipit-source-id: e734d76006ce937fadd1cb673035db85a3e838dd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48040
Changelog: [internal]
We need more expectations for a new test we're writing. This just adds:
* `expect(received).toBeLessThanOrEqual(expected)`
* `expect(received).toBeGreaterThanOrEqual(expected)`
Reviewed By: sammy-SC
Differential Revision: D66601921
fbshipit-source-id: 0a73f7757117ed790b95796b259244c8259136b7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48006
Changelog: [internal]
This implements symbolication of error stack traces in Fantom tests. We just needed to ask Metro to generate source maps and use the `source-map` package to process the stack traces that we get back from the runtime.
Reviewed By: sammy-SC
Differential Revision: D66577818
fbshipit-source-id: 672c66c246ad8646646d5ed31cabca39eb4f7aca
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47994
Changelog: [internal]
This adds a few hacks to improve errors messages in Fantom tests. Before, we were only logging the error message. After this, we log the message and the full (unsymbolicated for now) stack, including a pretty print of the exact location of the error.
For errors thrown from `expect` functions, the stack trace is modified to remove the "infra" lines from the stack.
The next step is symbolicating the errors using source maps generated by metro.
Reviewed By: javache
Differential Revision: D66555063
fbshipit-source-id: 17bd23cb30429a17e99f13f934c45e001120bbb3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47871
Changelog: [internal]
No need to keep going back to save test files when we change C++ files and need to re-run tests :)
Reviewed By: javache
Differential Revision: D66293212
fbshipit-source-id: dc232e1d3f7f8ae1578e894ce14bd21ccf3c8ade
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47870
Changelog: [internal]
This flag allows us to run optimized mode by using the right buck modes for the Fantom CLI, using minified + dev in Metro and building bytecode using Buck as well.
It's disabled by default but in the future we can enable it based on the configuration in the test file (e.g.: if it's a benchmark) or we can run tests in both modes by default to catch problems caused by the differences between environments.
Reviewed By: rshest
Differential Revision: D66292709
fbshipit-source-id: d25294b739ff6a67507990241784b838d5b30dcd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47758
Changelog: [internal]
This helps with debugging when adding logs in native code. By default they're logged to stderr and not shown in the Jest output, but we can opt into getting them with this new flag.
Reviewed By: sammy-SC
Differential Revision: D66232572
fbshipit-source-id: d507fa4438ae46988fafc92123d0954ab3d27631
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47700
Changelog: [internal]
Add support for the string parameter for `toThrow` to assert for specific error messages.
Reviewed By: sammy-SC
Differential Revision: D66118001
fbshipit-source-id: 8c04cd20d4ad17163ec0c7bf943c429507a97985
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47699
Changelog: [internal]
Implements a `jest.fn()` and a subset of methods in `expect` using them (`.toHaveBeenCalled()` and `.toHaveBeenCalledTimes()`).
Reviewed By: sammy-SC
Differential Revision: D66118002
fbshipit-source-id: 5422307d68967d7d8b4c4d5155a45926f8fc8cae
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47658
Changelog: [internal]
AppRegistry logs are showing up again in Fantom because we changed the order and now they're not necessarily showing up last.
This fixes that by filtering them out in any position.
Reviewed By: sammy-SC
Differential Revision: D66094274
fbshipit-source-id: bd37394252ee6309f7093567f9a2b73b641938ce
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47646
changelog: [internal]
In order to control scheduling of tests, test setup must be separated from test running. This is because of how internal scheduling of React Native is restricted until bundle is loaded via BufferedRuntimeExecutor. This is the reason for executing tests by calling global function `$$RunTests$$`. This is not a pretty solution but it is hidden within testing infrastructure and users of our test infra are not exposed to this.
There is a new method exposed to JavaScript: flushMessageQueue. This will flush everything that is inside of message queue. This is the queue where tasks are queued whenever RuntimeScheduler enqueues something by calling `runtimeExecutor_`.
Reviewed By: christophpurrer
Differential Revision: D65951894
fbshipit-source-id: 2e8e0c10fbeb998f4a51ee6d01ef229eb5f70448
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47612
Changelog: [internal]
Just using babel-register so we can use Flow types in the code for the RN integration tests runner.
Reviewed By: sammy-SC
Differential Revision: D65948801
fbshipit-source-id: 6c54b0463fe4b71c818ff1c4faa973cc8b13b5d2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47615
Changelog: [internal]
Fixes `.not` not being applied in some cases, and no logging the "not" label in case of error, and `.toBe` being flipped.
Reviewed By: javache
Differential Revision: D65952221
fbshipit-source-id: 030c0597b661d34e6324d69e5676375150a74f2e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109
Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.
For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.
Changelog:
[Internal]
Reviewed By: GijsWeterings
Differential Revision: D64569485
fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
Summary:
this PR fixes a few small ESLint issues that were showing up under PR diffs.
## Changelog:
[INTERNAL] [FIXED] - Fix various ESLint issues
Pull Request resolved: https://github.com/facebook/react-native/pull/46379
Test Plan: ran JS tests + linter; all passing
Reviewed By: cipolleschi
Differential Revision: D62385788
Pulled By: NickGerleman
fbshipit-source-id: b33d7ade4696bbaed2ac1a3fc2e0b3dff9bb04b7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42690
Issues triggered by `InspectorProxy*` tests under `packages/dev-middleware` (T169943794) can be root-caused to `dev-middleware` performing Babel registration within a test run, after Jest has hooked its own transformer.
Babel registration is only required when running this code (`dev-middleware`, etc) directly from source - we already have the `BUILD_EXCLUDE_BABEL_REGISTER` mechanism to strip it out from production builds, but we currently don't prevent registration under tests, where Jest's transformer should be allowed to do its work.
This adds the same `babel-plugin-transform-define` mechanism that we use for production builds to the Jest transformer.
Changelog:
[Internal] Prevent inadvertent Babel registration during running of repo tests
Reviewed By: huntie
Differential Revision: D53125777
fbshipit-source-id: 1f0a20315c96edaf79054e29a80c7a9561e5b352