lundi 4 mars 2019

Simulate is meant to be run on 1 node = 0 found : Jest enzyme

I am new to unit testing and trying to test the following method , if possible

Here is the method - using jest and enzyme. Trying to test without using spy functions

removeParameters(id){
delete this.state.dataSetList[id]
this.setState({
dataSetList: this.state.dataSetList
})
this.props.addDataSetList({ dataSetList: this.state.dataSetList })
}

Here is what I have for my test so far:

 it (' removeParameters : should return DefaultData props correct',() => {
 baseProps.addDataSetList.mockClear();
 wrapper.setState({
 dataSetList: []
 });
  wrapper.update();
 expect(wrapper.instance().removeParameters('test')).toEqual();
 expect(baseProps.addDataSetList).toHaveBeenCalled();
 expect(toJson(wrapper)).toMatchSnapshot();
});

Using Jest and Enzyme

Aucun commentaire:

Enregistrer un commentaire