javascript - stubbing process.exit with jest -
i have code like
function myfunc(condition){ if(condition){ process.exit(error_code) } } how can test in jest? overwriting exit in process jest.fn() , returning after test doesn't work, since process exits
you use jest.spyon call original method well:
const exit = jest.spyon(process, 'exit'); //run test expect(exit).tohavebeencalledwith('error_code');
Comments
Post a Comment