I have code that does something like
function myFunc(condition){
if(condition){
process.exit(ERROR_CODE)
}
}
How can I test this in Jest? Overwriting exit in process with jest.fn() and returning it back after the test doesn't work, since the process exits
You could use
jest.spyOnas this will call the original method as well: