diff --git a/index.js b/index.js index 05df5d4..fa548b3 100644 --- a/index.js +++ b/index.js @@ -7,10 +7,4 @@ * @flow */ -'use strict'; - -const ReactShallowRenderer = require('./src/ReactShallowRenderer'); - -// TODO: decide on the top-level export form. -// This is hacky but makes it work with both Rollup and Jest. -module.exports = ReactShallowRenderer.default || ReactShallowRenderer; +export {default} from './src/ReactShallowRenderer'; diff --git a/src/__tests__/ReactShallowRenderer-test.js b/src/__tests__/ReactShallowRenderer-test.js index 3974058..84b52ad 100644 --- a/src/__tests__/ReactShallowRenderer-test.js +++ b/src/__tests__/ReactShallowRenderer-test.js @@ -8,21 +8,13 @@ * @jest-environment node */ -'use strict'; +import * as PropTypes from 'prop-types'; +import * as React from 'react'; +import ReactShallowRenderer from 'react-shallow-renderer'; -let createRenderer; -let PropTypes; -let React; +const createRenderer = ReactShallowRenderer.createRenderer; describe('ReactShallowRenderer', () => { - beforeEach(() => { - jest.resetModules(); - - createRenderer = require('react-shallow-renderer').createRenderer; - PropTypes = require('prop-types'); - React = require('react'); - }); - it('should call all of the legacy lifecycle hooks', () => { const logs = []; const logger = message => () => logs.push(message) || true; diff --git a/src/__tests__/ReactShallowRendererHooks-test.js b/src/__tests__/ReactShallowRendererHooks-test.js index ee5dfef..dabeb51 100644 --- a/src/__tests__/ReactShallowRendererHooks-test.js +++ b/src/__tests__/ReactShallowRendererHooks-test.js @@ -8,18 +8,12 @@ * @jest-environment node */ -'use strict'; +import * as React from 'react'; +import ReactShallowRenderer from 'react-shallow-renderer'; -let createRenderer; -let React; +const createRenderer = ReactShallowRenderer.createRenderer; describe('ReactShallowRenderer with hooks', () => { - beforeEach(() => { - jest.resetModules(); - createRenderer = require('react-shallow-renderer').createRenderer; - React = require('react'); - }); - it('should work with useState', () => { function SomeComponent({defaultName}) { const [name] = React.useState(defaultName); diff --git a/src/__tests__/ReactShallowRendererMemo-test.js b/src/__tests__/ReactShallowRendererMemo-test.js index 5ce0944..4ec343e 100644 --- a/src/__tests__/ReactShallowRendererMemo-test.js +++ b/src/__tests__/ReactShallowRendererMemo-test.js @@ -8,21 +8,13 @@ * @jest-environment node */ -'use strict'; +import * as PropTypes from 'prop-types'; +import * as React from 'react'; +import ReactShallowRenderer from 'react-shallow-renderer'; -let createRenderer; -let PropTypes; -let React; +const createRenderer = ReactShallowRenderer.createRenderer; describe('ReactShallowRendererMemo', () => { - beforeEach(() => { - jest.resetModules(); - - createRenderer = require('react-shallow-renderer').createRenderer; - PropTypes = require('prop-types'); - React = require('react'); - }); - it('should call all of the legacy lifecycle hooks', () => { const logs = []; const logger = message => () => logs.push(message) || true;