2

I have a component with following constructor.

constructor(props) {
  super(props);
  this.state = {
    displayCluster: {}
  };
}

In my test, when I do shallow render and try to test the null state value of displayCluster. It prompts for error.

const wrapper = shallow<MyComponent />
t.equal(wrapper.state('displayCluster'), null, 'initially state should be null');
TypeError: Cannot read property 'displayCluster' of null
Varun Gupta
  • 1,419
  • 6
  • 28
  • 53

0 Answers0