From 8f8e215df1ae86155a2a69e8be6722ec25c4702e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 14 Jul 2016 12:02:39 +0100 Subject: [PATCH] Fix TestUtils crash with NODE_ENV=production (#7246) 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. (cherry picked from commit 27d7592cf63253b318c9feac564c8ea2fe9d8383) --- 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); };