I am using msw with Testing Library and trying to mock an API call to return the content of a JSON file.
Using the example in the documentation, I am trying this code:
rest.get(endpoint, (req, res, ctx) => {
const json = require('./myJsonFile.json');
return res(ctx.json(json));
});
but I keep having SonarQube complaining about:
Refactor this function to always return the same type.
Any idea why and how I could refactor this function?
Thank you very much.