alexjoverm / alexjoverm/vue-testing-series
Question about mocking axios: What if i also want to return error from async call?
未关闭
- 主要语言
- JavaScript
- 星标
- 157
- 派生
- 38
- PR 合并指标
- 30 天内没有已合并 PR
描述
So for your mock, axios return a promise with value which is a happy path. However, what if i want to mock it to return an error.
Wonder if i can do like this
```
const func = jest.fn();
jest.mock('axios', () => {
get: func
});
```
then in each test case, can i do func.mockReturnValue for happy and error case?
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。