How to test an axios interceptor with mocha, chai and sino

Viewed 179

I am having trouble testing the axios interceptor and would like to know if there is a way to do it. I have tried to search for information on the net but I have not been able to get an answer that gives me a solution.

module.exports = (axiosInstance) => {
  axiosInstance.interceptors.response.use((res) => {
    res.body = res.data;
    res.code = res.status;
    delete res.data;
    delete res.status;
    return res;
  });
};

If anyone has any idea how to perform unit tests on the axios interceptor, I would appreciate it.

0 Answers
Related