Skip to content

Commit

Permalink
Move error into class init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Mar 6, 2024
1 parent 61468c3 commit f93af47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/react-test-renderer/__tests__/shallow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
'use strict';

describe('shallow', () => {
it('throws an error on import', () => {
it('throws an error on init', () => {
const ReactShallowRenderer = require('../shallow.js').default;
expect(() => {
require('../shallow.js');
// eslint-disable-next-line no-new
new ReactShallowRenderer();
}).toThrow(
'react-test-renderer is deprecated. To use react-test-renderer/shallow, import react-shallow-renderer directly. See https://react.dev/warnings/react-test-renderer'
);
Expand Down
10 changes: 7 additions & 3 deletions packages/react-test-renderer/npm/shallow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

throw new Error(
'react-test-renderer is deprecated. To use react-test-renderer/shallow, import react-shallow-renderer directly. See https://react.dev/warnings/react-test-renderer'
);
function ReactShallowRenderer() {
throw new Error(
'react-test-renderer is deprecated. To use react-test-renderer/shallow, import react-shallow-renderer directly. See https://react.dev/warnings/react-test-renderer'
);
}

module.exports = ReactShallowRenderer;
4 changes: 2 additions & 2 deletions packages/react-test-renderer/shallow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
* @flow
*/

import * as ReactShallowRenderer from './npm/shallow.js';
export {ReactShallowRenderer as default};
import ReactShallowRenderer from './npm/shallow.js';
export default ReactShallowRenderer;

0 comments on commit f93af47

Please sign in to comment.