Answer the question
In order to leave comments, you need to log in
Testing axios request in enzyme + jest?
Good afternoon. I want to test a POST request to the server using axios. For some reason, the function is not called then
after sending the request:
it('should have ok response', () => {
const data = [];
const createBoard = () => {
axios.post(`${API_ROOT}/boards`).then(response => {
console.log('data:', response);
return data.push(response.data);
})
}
const component = shallow(<CreateBoardButton onClick={createBoard} text="CREATE BOARD" />);
component.find('#create_board_button').simulate('click');
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question