Relative Content

Tag Archive for javascriptunit-testingtestingjestjs

How to test that a function returned without doing anything

I’m writing a suite of Jest tests, and the following question came up. How can I test that a function simply returns if it receives an invalid argument? For example, I would like to test that the function changeAge below returns immediately if it receives a newAge or id that is not a whole number.