CodeVetter · Repo Unpack · Testing signals
react/react-native
Two JS test systems: Jest 29 unit tests in __tests__/*-test.js (custom preprocessor + haste resolver that strips `exports`, ios/android platforms, fake timers globally) and Fantom *-itest.js integration tests that run JS on Hermes against the real C++ Fabric/mounting stack with a mock host platform — Fantom files must live under packages/react-native. Native testing: Gradle test task for ReactAndroid, scripts/objc-test.sh + RNTesterUnitTests/RCTTest for iOS. CI in test-all.yml gates on lint, test_js, build_js_types, Fantom (with two retry rounds), Android/iOS builds, helloworld e2e, RNTester e2e and Maestro cloud runs.
- Jest config: testRegex '/__tests__/.*-test(\.fb)?\.js$' (the .fb suffix runs Meta-internal tests), haste platforms ['ios','android'] default ios, fakeTimers enabled globally (modern), testEnvironment node, coverage collected from packages/react-native/Libraries/**/*.js and src/**/*.js.
- Jest resolution diverges deliberately from Metro: a custom resolver (packages/jest-preset/jest/resolver.js) strips package.json `exports`, so moduleNameMapper aliases map 'react-native/setup-env', 'react-native/react-private-interface' and 'react-native/unstable-internals-do-not-use' to their src/ files; all sources transform through jest/preprocessor.js.
- Roughly 234 *-test.js files exist under __tests__ dirs (find count) — concentrated in packages/react-native/Libraries and src/private plus per-package suites (community-cli-plugin, dev-middleware, codegen generators/parsers __tests__).
- Fantom (~202 *-itest.js files) is the integration/benchmark runner: tests execute on Hermes with the real C++ Fabric renderer, TurboModules and bridgeless runtime against a mock host platform; API = Fantom.createRoot/runTask/scrollTo/installTimerMock on a deterministic virtual clock; docblock pragmas @fantom_flags, @fantom_mode, @fantom_native_opt, @fantom_js_opt, @fantom_js_bytecode generate test-matrix variants including wildcard '*'.
- Fantom asserts real layout: examples show root.getRenderedOutput({includeLayoutMetrics:true}).toJSX() producing <rn-view layoutMetrics-frame=.../> and element.getBoundingClientRect() returning Yoga-computed metrics — capabilities Jest can't provide; mounting instructions are inspectable via root.takeMountingManagerLogs().
- CI Fantom path: test-all.yml job build_fantom_runner (8-core-ubuntu container reactnativecommunity/react-native-android) then run_fantom_tests uses ./.github/workflows/fantom-tests.yml with two automatic retry rounds (run_fantom_tests_retry_1/2, second round sets fail-on-error: true).
- E2E coverage: e2e-android-rntester.yml / e2e-ios-rntester.yml / e2e-*-templateapp.yml run RNTester and template apps on emulators/simulators; test_maestro_cloud_{android,ios} push rntester release builds to Maestro Cloud on main pushes and same-repo PRs; helloworld e2e jobs (test_android_helloworld, test_ios_helloworld) validate the template path.
- Native unit tests: `yarn test-android` runs ./gradlew :packages:react-native:ReactAndroid:test (JUnit/Robolectric under ReactAndroid/src/test); `yarn test-ios` runs scripts/objc-test.sh against packages/rn-tester's RNTesterUnitTests and RCTTest infrastructure.
- Type/API regression gates: `yarn flow-check` (flow full-check, flow-bin 0.332), `yarn test-generated-typescript` (tsc -p __typetests__/tsconfig.json), js-api-diff job via scripts/js-api/diff-api-snapshot (workflow api-changes.yml), and validate-cxx-api-snapshots.yml for the C++ API snapshots.
- Lint/format gates: `yarn lint` = eslint --max-warnings 0; `yarn format-check` fans out to prettier (js/md/yaml), clang-format (cpp), format-kotlin/format-java/format-python/format-swift scripts, each with pinned toolchain packages; shellcheck runs via .github/workflow-scripts/analyze_scripts.sh; markdownlint via lint-markdown.
- Uncovered/soft spots: testPathIgnorePatterns excludes sdks/hermes and Libraries/Renderer implementations from Jest; Fantom is limited to packages/react-native internals (no app-level testing); C++ sampling profiler (FANTOM_PROFILE_CPP) and JS/C++ debugging (FANTOM_DEBUG_JS/CPP) only work on Meta infrastructure.