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