From ef79ee3c072da371aac9d55cdc64228a49bc7a7b Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 11 Jul 2016 11:48:57 +0100 Subject: [PATCH] Fix TestUtils crash with NODE_ENV=production MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I caused it with #7189. We generally don’t recommend running TestUtils in production environment but this is technically a regression. Fixes #7231. --- src/test/ReactTestUtils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/ReactTestUtils.js b/src/test/ReactTestUtils.js index 746a185b1ae4d..d454b9150daa2 100644 --- a/src/test/ReactTestUtils.js +++ b/src/test/ReactTestUtils.js @@ -410,9 +410,11 @@ NoopInternalComponent.prototype = { var ShallowComponentWrapper = function(element) { // TODO: Consolidate with instantiateReactComponent - this._debugID = nextDebugID++; - var displayName = element.type.displayName || element.type.name || 'Unknown'; - ReactInstrumentation.debugTool.onSetDisplayName(this._debugID, displayName); + if (__DEV__) { + this._debugID = nextDebugID++; + var displayName = element.type.displayName || element.type.name || 'Unknown'; + ReactInstrumentation.debugTool.onSetDisplayName(this._debugID, displayName); + } this.construct(element); };