是否可以使用MSW和Jest来模拟离线网络条件?或者,非基于MSW的解决方案就足够了。我也不想模拟navigator.onLine,因为我想在网络请求由于离线而失败时测试错误路径。
发布于 2021-03-09 06:19:52
是的,您可以模拟网络错误:
rest.get('/user', (_, res) => {
return res.networkError('Custom network error message')
})https://stackoverflow.com/questions/66491883
复制相似问题