Skip to content

Commit fe5ce4e

Browse files
authored
fix[react-devtools/store-test]: fork the test to represent current be… (#29777)
## Summary The test started to fail after #29088. Fork the test and the expected store state for: - React 18.x, to represent the previous behavior - React >= 19, to represent the current RDT behavior, where error can't be connected to the fiber, because it was not yet mounted and shared with DevTools. Ideally, DevTools should start keeping track of such fibers, but also distinguish them from some that haven't mounted due to Suspense or error boundaries.
1 parent 90499a7 commit fe5ce4e

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

packages/react-devtools-shared/src/__tests__/store-test.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,8 +1915,12 @@ describe('Store', () => {
19151915
});
19161916
});
19171917

1918-
// @reactVersion >= 18.0
1919-
it('from react get counted', () => {
1918+
// In React 19, JSX warnings were moved into the renderer - https://github.com/facebook/react/pull/29088
1919+
// When the error is emitted, the source fiber of this error is not yet mounted
1920+
// So DevTools can't connect the error and the fiber
1921+
// TODO(hoxyq): update RDT to keep track of such fibers
1922+
// @reactVersion >= 19.0
1923+
it('from react get counted [React >= 19]', () => {
19201924
function Example() {
19211925
return [<Child />];
19221926
}
@@ -1938,6 +1942,31 @@ describe('Store', () => {
19381942
`);
19391943
});
19401944

1945+
// @reactVersion >= 18.0
1946+
// @reactVersion < 19.0
1947+
it('from react get counted [React 18.x]', () => {
1948+
function Example() {
1949+
return [<Child />];
1950+
}
1951+
function Child() {
1952+
return null;
1953+
}
1954+
1955+
withErrorsOrWarningsIgnored(
1956+
['Warning: Each child in a list should have a unique "key" prop'],
1957+
() => {
1958+
act(() => render(<Example />));
1959+
},
1960+
);
1961+
1962+
expect(store).toMatchInlineSnapshot(`
1963+
✕ 1, ⚠ 0
1964+
[root]
1965+
▾ <Example> ✕
1966+
<Child>
1967+
`);
1968+
});
1969+
19411970
// @reactVersion >= 18.0
19421971
it('can be cleared for the whole app', () => {
19431972
function Example() {

0 commit comments

Comments
 (0)