From 9c87aef67f874afc24b3ebaa6f9b71f5fb85dc9b Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 4 Mar 2014 12:59:55 -0500 Subject: [PATCH] Fix stale usage of emptyObject in cloneWithProps-test. After we run `require('mock-modules').dumpCache()`, the object exported by the `emptyObject` module will no longer be identical to previously exported objects, so tests like `expect(component.refs).toBe(emptyObject)` will fail. Note that this behavior only manifests itself in tests, because of course we do not call `dumpCache` in production code. We could consider storing the `emptyObject` globally to thwart the effects of `dumpCache`, but it's more idiomatic simply to re-`require` the latest version of `emptyObject`. --- src/utils/__tests__/cloneWithProps-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/__tests__/cloneWithProps-test.js b/src/utils/__tests__/cloneWithProps-test.js index 2b1ee1132d..b51e2ab03c 100644 --- a/src/utils/__tests__/cloneWithProps-test.js +++ b/src/utils/__tests__/cloneWithProps-test.js @@ -24,12 +24,12 @@ require('mock-modules').dontMock('cloneWithProps'); var mocks = require('mocks'); var cloneWithProps = require('cloneWithProps'); -var emptyObject = require('emptyObject'); var React; var ReactTestUtils; var onlyChild; +var emptyObject; describe('cloneWithProps', function() { @@ -37,6 +37,7 @@ describe('cloneWithProps', function() { React = require('React'); ReactTestUtils = require('ReactTestUtils'); onlyChild = require('onlyChild'); + emptyObject = require('emptyObject'); }); it('should clone a DOM component with new props', function() {