Testing error handling?
See original GitHub issueThis just a question, not a real issue, but in your section on Error Handling you have the following example:
function* checkout(getState) {
while( yield take(types.CHECKOUT_REQUEST) ) {
try {
const cart = getState().cart
yield call(api.buyProducts, cart)
yield put(actions.checkoutSuccess(cart))
} catch(error) {
yield put(actions.checkoutFailure(error))
}
}
}
How would I go about testing the error case? I’d like to test what happens when the function passed in the call
statement rejects its Promise or throws an Error.
The best thing I can think of is trying to mock the call
function to just throw an error, but that seems messier than I’d like. Any ideas? Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Reactions:10
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error handling Testing - H2k Infosys
Error handling testing is a type of software testing that is performed to check whether the system is capable of or able to...
Read more >Testing Error Handling | Shakacode
You can simulate error conditions by manually placing =raise "any error message"= statements in your code, and then testing, say in the UI ......
Read more >Testing for Improper Error Handling - OWASP Foundation
Analyse the expected input type (strings, integers, JSON, XML, etc.). Fuzz every input point based on the previous steps to have a more...
Read more >What is Error Handling Testing? (Software Testing Interview ...
In this session, I have answered What is Error Handling Testing ?
Read more >Software Testing Errors to look out for (with examples)
Programmers usually pass an 'Error Flag' in the function to keep track of the success or failure of the function. It is advisable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You don’t have to mock,
yield call(...)
doesn’t execute anything, to test the generator you provide it with dummy responses. To simulate a promise rejection, callthrow
on the iteratorCan this go in the docs? Please?