Skip to content

[test] Exclude repository root from assertions#245

Closed
everettbu wants to merge 1 commit into
mainfrom
sebbie/12-15-_test_exclude_repository_root_from_assertions
Closed

[test] Exclude repository root from assertions#245
everettbu wants to merge 1 commit into
mainfrom
sebbie/12-15-_test_exclude_repository_root_from_assertions

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35361
Original author: eps1lon


The repository root was hidden in string length assertions. Those broke once you tested React deeper in your filesystem.

Added the repo root behind a global __REACT_ROOT_PATH_TEST__ since that's used in a couple of places. Defining that for each test makes it annoying to move test file around.

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 15, 2025
@greptile-apps

greptile-apps Bot commented Dec 15, 2025

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR fixes a test brittleness issue where path assertions would break when React is tested from different filesystem locations. The changes centralize repo root path handling by introducing a global __REACT_ROOT_PATH_TEST__ variable.

Key changes:

  • Added global __REACT_ROOT_PATH_TEST__ in setupTests.js to store the repository root path
  • Updated path normalization logic in test files to use the global variable instead of calculating paths locally
  • Adjusted string length assertions in ReactFlightDOMEdge-test.js to account for normalized paths (reduced by ~25 characters to compensate for the replaced path)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it only fixes test infrastructure without changing production code
  • All changes are confined to test setup and test files. The refactoring centralizes path normalization logic, making tests more robust across different filesystem locations. The adjusted size assertions correctly account for the path length differences.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
scripts/jest/setupTests.js 5/5 added global __REACT_ROOT_PATH_TEST__ variable for normalizing paths in tests
packages/internal-test-utils/debugInfo.js 5/5 replaced local repoRoot with global __REACT_ROOT_PATH_TEST__ for path normalization
packages/react-server-dom-webpack/src/tests/ReactFlightDOMEdge-test.js 5/5 added normalizeSerializedContent helper and adjusted size assertions to account for normalized paths

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Dec 15, 2025
@everettbu everettbu deleted the sebbie/12-15-_test_exclude_repository_root_from_assertions branch December 15, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants