Fix expect() slipping into the non-test code
Dan Abramov committed
Apr 21, 2016 at 22:23 UTC
e20d366ea85631e6d8326a304c0375c02687eb3c
1 file changed
+23
-4
src/isomorphic/devtools/ReactComponentTreeDevtool.js
+23
-4
@@ -11,6 +11,8 @@
11
12
'use strict';
13
14
+var invariant = require('invariant');
15
+
16
var unmountedContainerIDs = [];
17
var allChildIDsByContainerID = {};
18
var tree = {};
@@ -65,10 +67,27 @@ var ReactComponentTreeDevtool = {
67
68
nextChildIDs.forEach(nextChildID => {
69
var item = tree[nextChildID];
68
- expect(item).toBeDefined();
69
- expect(item.isComposite).toBeDefined();
70
- expect(item.displayName).toBeDefined();
71
- expect(item.childIDs || item.text).toBeDefined();
70
+
71
+ invariant(
72
+ item,
73
+ 'Expected devtool events to fire for the child ' +
74
+ 'before its parent includes it in onSetChildren().'
75
+ );
76
+ invariant(
77
+ item.isComposite != null,
78
+ 'Expected onSetIsComposite() to fire for the child ' +
79
+ 'before its parent includes it in onSetChildren().'
80
+ );
81
+ invariant(
82
+ item.displayName != null,
83
+ 'Expected onSetDisplayName() to fire for the child ' +
84
+ 'before its parent includes it in onSetChildren().'
85
+ );
86
+ invariant(
87
+ item.childIDs != null || item.text != null,
88
+ 'Expected either onSetChildren() or onSetText() to fire for the child ' +
89
+ 'before its parent includes it in onSetChildren().'
90
+ );
91
92
if (tree[nextChildID] && prevChildIDs.indexOf(nextChildID) === -1) {
93
tree[nextChildID].parentID = id;