From 6d31da215d839b44b03aa0bf54ad9ba0196e536e Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Wed, 18 Mar 2020 13:03:21 +0100 Subject: [PATCH] imp: Deprecate shallow (#264) --- src/helpers/debugShallow.js | 4 ++-- src/shallow.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/helpers/debugShallow.js b/src/helpers/debugShallow.js index 896e059d..80e36e68 100644 --- a/src/helpers/debugShallow.js +++ b/src/helpers/debugShallow.js @@ -1,6 +1,6 @@ // @flow import * as React from 'react'; -import shallow from '../shallow'; +import { shallowInternal } from '../shallow'; import format from './format'; /** @@ -10,7 +10,7 @@ export default function debugShallow( instance: ReactTestInstance | React.Element, message?: any ) { - const { output } = shallow(instance); + const { output } = shallowInternal(instance); if (message) { console.log(`${message}\n\n`, format(output)); diff --git a/src/shallow.js b/src/shallow.js index e07b123c..576ac913 100644 --- a/src/shallow.js +++ b/src/shallow.js @@ -1,11 +1,12 @@ // @flow import * as React from 'react'; import ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-line import/no-extraneous-dependencies +import { printDeprecationWarning } from './helpers/errors'; /** * Renders test component shallowly using react-test-renderer/shallow */ -export default function shallow( +export function shallowInternal( instance: ReactTestInstance | React.Element ) { const renderer = new ShallowRenderer(); @@ -16,3 +17,11 @@ export default function shallow( output: renderer.getRenderOutput(), }; } + +export default function shallow( + instance: ReactTestInstance | React.Element +) { + printDeprecationWarning('shallow'); + + return shallowInternal(instance); +}