How to test a prop update on React component
问题 What is the correct way of unit testing a React component prop update. Here is my test fixture; describe('updating the value', function(){ var component; beforeEach(function(){ component = TestUtils.renderIntoDocument(<MyComponent value={true} />); }); it('should update the state of the component when the value prop is changed', function(){ // Act component.props.value = false; component.forceUpdate(); // Assert expect(component.state.value).toBe(false); }); }); This works fine and the test