score:2

Accepted answer

If you want to use shallow there is a way to get the shallow wrapper of one of the children using the dive method. If you have to wrap your components with BrowserRouter frequently on the test, maybe it's worth it to have a helper method for this like:

function shallowWithBrowserRouter(component) {
   return shallow(<BrowserRouter>{component}</BrowserRouter>).childAt(0).dive();
}

score:0

Able to work something out but how could I improve the following answer.

Switched shallow to Mount in order to render children components

  it("should  call  button click 3 times", () => {
// Reset info from possible previous calls of these mock functions:
 wrapper.setProps({
});
wrapper.setState({ 
});
wrapper.find('.add-edit-button').at(0).simulate("click");
wrapper.find('.add-edit-button').at(1).simulate("click");
wrapper.find('.add-edit-button').at(2).simulate("click");

expect(toJson(wrapper)).toMatchSnapshot();
 });

Related Query

More Query from same tag