diff --git a/packages/react-test-renderer/shallow.js b/packages/react-test-renderer/shallow.js index 3b36f734e4f84..f4e93d121e5c7 100644 --- a/packages/react-test-renderer/shallow.js +++ b/packages/react-test-renderer/shallow.js @@ -4,28 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow */ -import ReactShallowRenderer from 'react-shallow-renderer'; -import {enableReactTestRendererWarning} from 'shared/ReactFeatureFlags'; - -let Renderer = ReactShallowRenderer; - -if (enableReactTestRendererWarning === true) { - const emptyObject = {}; - Renderer = class ReactShallowRendererWithWarning extends ( - ReactShallowRenderer - ) { - render(element, context = emptyObject) { - if (__DEV__) { - console.warn( - 'react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer', - ); - } - - return super.render(element, context); - } - }; -} - -export default Renderer; +export {default} from 'react-shallow-renderer'; diff --git a/packages/react-test-renderer/src/__tests__/ShallowRenderer-test.internal.js b/packages/react-test-renderer/src/__tests__/ShallowRenderer-test.internal.js deleted file mode 100644 index 1f921036dccc8..0000000000000 --- a/packages/react-test-renderer/src/__tests__/ShallowRenderer-test.internal.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @emails react-core - */ - -'use strict'; - -let React; -let ReactShallowRenderer; -let ReactFeatureFlags; - -function HelloWorld() { - return

Hello, world!

; -} - -describe('ShallowRenderer', () => { - beforeEach(() => { - jest.resetModules(); - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - React = require('react'); - ReactShallowRenderer = require('../../shallow.js').default; - }); - - it('should render without warnings without enableReactTestRendererWarning', () => { - ReactFeatureFlags.enableReactTestRendererWarning = false; - const renderer = new ReactShallowRenderer(); - expect(renderer.render()).toMatchSnapshot(); - }); - - it('should render with warnings with enableReactTestRendererWarning', () => { - ReactFeatureFlags.enableReactTestRendererWarning = true; - const renderer = new ReactShallowRenderer(); - expect(() => { - renderer.render(); - }).toWarnDev( - "Warning: React's Shallow Renderer export will be removed in a future release. Please use @testing-library/react instead.", - {withoutStack: true}, - ); - }); -}); diff --git a/packages/react-test-renderer/src/__tests__/__snapshots__/ShallowRenderer-test.internal.js.snap b/packages/react-test-renderer/src/__tests__/__snapshots__/ShallowRenderer-test.internal.js.snap deleted file mode 100644 index ce181e1388af8..0000000000000 --- a/packages/react-test-renderer/src/__tests__/__snapshots__/ShallowRenderer-test.internal.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ShallowRenderer should render without warnings without enableReactTestRendererWarning 1`] = ` -

- Hello, world! -

-`; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 1d704ea4dcf99..b368dddc05f2e 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -89,7 +89,7 @@ export const disableClientCache = true; export const enableServerComponentKeys = true; export const enableInfiniteRenderLoopDetection = false; -export const enableReactTestRendererWarning = false; +export const enableReactTestRendererWarning = true; // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType);