alexjoverm / alexjoverm/vue-testing-series
Question about mocking axios: What if i also want to return error from async call?
Aperta
- Lingua principale
- JavaScript
- Stelle
- 157
- Fork
- 38
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.