From 677330a6d6b01b49bc5127b37cc8869dddde4d0b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 25 Feb 2026 03:17:00 -0800 Subject: [PATCH] Exclude benchmark tests by default, add --benchmarks flag (#55725) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55725 changelog: [internal] By default, `yarn fantom` now excludes benchmark tests (`*-benchmark-itest.js` files) to speed up regular test runs. Benchmark tests are typically slower and used for performance analysis rather than correctness testing. Excluding them by default improves the developer experience for everyday test runs. To run benchmark tests, use the new `--benchmarks` flag: ``` yarn fantom --benchmarks ``` Reviewed By: andrewdacenko Differential Revision: D92150163 fbshipit-source-id: 4c40ef1ba542c4856221373d8239ba603e8f6620 --- .../react-native-fantom/config/jest.config.js | 7 ++++++- .../runner/EnvironmentOptions.js | 1 + scripts/fantom.sh | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/private/react-native-fantom/config/jest.config.js b/private/react-native-fantom/config/jest.config.js index adf10408e5c..34efa5467e7 100644 --- a/private/react-native-fantom/config/jest.config.js +++ b/private/react-native-fantom/config/jest.config.js @@ -29,7 +29,12 @@ module.exports = { ] /*:: as $ReadOnlyArray */, // This allows running Meta-internal tests with the `-test.fb.js` suffix. testRegex: '/__tests__/.*-itest(\\.fb)?\\.js$', - testPathIgnorePatterns: baseConfig.testPathIgnorePatterns, + testPathIgnorePatterns: [ + ...baseConfig.testPathIgnorePatterns, + ...(process.env.FANTOM_INCLUDE_BENCHMARKS != null + ? [] + : ['benchmark-itest']), + ] /*:: as ReadonlyArray */, transformIgnorePatterns: ['.*'], testRunner: '/private/react-native-fantom/runner/index.js', watchPathIgnorePatterns: ['/private/react-native-fantom/build/'], diff --git a/private/react-native-fantom/runner/EnvironmentOptions.js b/private/react-native-fantom/runner/EnvironmentOptions.js index 553049aacaa..74e01269190 100644 --- a/private/react-native-fantom/runner/EnvironmentOptions.js +++ b/private/react-native-fantom/runner/EnvironmentOptions.js @@ -16,6 +16,7 @@ const VALID_ENVIRONMENT_VARIABLES = [ 'FANTOM_FORCE_CI_MODE', 'FANTOM_FORCE_OSS_BUILD', 'FANTOM_FORCE_TEST_MODE', + 'FANTOM_INCLUDE_BENCHMARKS', 'FANTOM_LOG_COMMANDS', 'FANTOM_PRINT_OUTPUT', 'FANTOM_DEBUG_JS', diff --git a/scripts/fantom.sh b/scripts/fantom.sh index 9ae47c1f23b..5a08cbf67e1 100755 --- a/scripts/fantom.sh +++ b/scripts/fantom.sh @@ -16,4 +16,20 @@ fi export NODE_OPTIONS='--max-old-space-size=8192' -yarn jest --config private/react-native-fantom/config/jest.config.js "$@" +# Parse arguments to check for --benchmarks flag +INCLUDE_BENCHMARKS=false +ARGS=() +for arg in "$@"; do + if [[ "$arg" == "--benchmarks" ]]; then + INCLUDE_BENCHMARKS=true + else + ARGS+=("$arg") + fi +done + +# When --benchmarks is passed, set env var so jest.config.js includes benchmark tests +if [[ "$INCLUDE_BENCHMARKS" == true ]]; then + FANTOM_INCLUDE_BENCHMARKS=1 yarn jest --config private/react-native-fantom/config/jest.config.js "${ARGS[@]}" +else + yarn jest --config private/react-native-fantom/config/jest.config.js "${ARGS[@]}" +fi