From 10fd37a21e14904dee24895fbf7ae0bc3ea7ecac Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 1 Jul 2019 12:30:07 +0100 Subject: [PATCH 1/2] pass tests --- index.test.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/index.test.js b/index.test.js index 6d0a87f..065c7bc 100644 --- a/index.test.js +++ b/index.test.js @@ -1,14 +1,21 @@ -const reactTestRenderer = require('react-test-renderer') -const MyComponent = require('./index.js') -const React = require('react') +let React; -describe('MyComponent', () => { - it('should render without errors', () => { - reactTestRenderer.create(React.createElement(MyComponent, {})).toJSON() - }) - it('should render without errors when imported after resetModules called', () => { - jest.resetModules() - const MyComponent = require('./index.js') - reactTestRenderer.create(React.createElement(MyComponent, {})).toJSON() - }) -}) +let ReactTestRenderer; +let MyComponent; + +describe("MyComponent", () => { + beforeEach(() => { + jest.resetModules(); + + MyComponent = require("./index.js"); + React = require("react"); + ReactTestRenderer = require("react-test-renderer"); + }); + it("should render without errors", () => { + ReactTestRenderer.create(React.createElement(MyComponent, {})).toJSON(); + }); + it("should render without errors when imported after resetModules called", () => { + const MyComponent = require("./index.js"); + ReactTestRenderer.create(React.createElement(MyComponent, {})).toJSON(); + }); +}); From a3bb8977004810fa07548917d0d9f417a24e76dd Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 1 Jul 2019 12:32:40 +0100 Subject: [PATCH 2/2] more --- index.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.test.js b/index.test.js index 065c7bc..c4921f7 100644 --- a/index.test.js +++ b/index.test.js @@ -15,7 +15,6 @@ describe("MyComponent", () => { ReactTestRenderer.create(React.createElement(MyComponent, {})).toJSON(); }); it("should render without errors when imported after resetModules called", () => { - const MyComponent = require("./index.js"); ReactTestRenderer.create(React.createElement(MyComponent, {})).toJSON(); }); });