@samitouri / QOS-React-1 / commits / fe5ce4e3e9

fix[react-devtools/store-test]: fork the test to represent current be… (#29777)

## Summary The test started to fail after https://github.com/facebook/react/pull/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.

Ruslan Lesiutin committed Jun 6, 2024 at 20:01 UTC fe5ce4e3e969aca4705b9973a6fdb5f132e03025
1 file changed +31 -2
packages/react-devtools-shared/src/__tests__/store-test.js
+31 -2
@@ -1915,8 +1915,12 @@ describe('Store', () => {
1915 });
1916 });
1917
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]', () => {
1924 function Example() {
1925 return [<Child />];
1926 }
@@ -1938,6 +1942,31 @@ describe('Store', () => {
1942 `);
1943 });
1944
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 +
1970 // @reactVersion >= 18.0
1971 it('can be cleared for the whole app', () => {
1972 function Example() {