1 year ago

#338771

test-img

Andres Teixeira

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

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.

node.js

mocha.js

chai

sinon

0 Answers

Your Answer

Accepted video resources