Check correct commit phase props in fuzz tester (#14129)
Adds a check to the existing fuzz tester to confirm that the props are set to the latest values in the commit phase. Only checks componentDidUpdate; we already have unit tests for the other lifecycles, so I think this is good enough. This is only a redundancy.
Andrew Clark committed
Nov 6, 2018 at 15:01 UTC
b020fb1148f2da7495bd1d5425af0622b71100d4
1 file changed
+10
-1
packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js
+10
-1
@@ -189,6 +189,7 @@ describe('ReactIncrementalTriangle', () => {
189
leafTriangles.push(this);
190
}
191
this.state = {isActive: false};
192
+ this.child = React.createRef(null);
193
}
194
activate() {
195
this.setState({isActive: true});
@@ -203,6 +204,14 @@ describe('ReactIncrementalTriangle', () => {
204
this.state.isActive !== nextState.isActive
205
);
206
}
207
+ componentDidUpdate() {
208
+ if (this.child.current !== null) {
209
+ const {prop: currentCounter} = JSON.parse(this.child.current.prop);
210
+ if (this.props.counter !== currentCounter) {
211
+ throw new Error('Incorrect props in lifecycle');
212
+ }
213
+ }
214
+ }
215
render() {
216
if (yieldAfterEachRender) {
217
ReactNoop.yield(this);
@@ -228,7 +237,7 @@ describe('ReactIncrementalTriangle', () => {
237
activeDepthProp,
238
activeDepthContext,
239
});
231
- return <span prop={output} />;
240
+ return <span ref={this.child} prop={output} />;
241
}
242
243
return (