Consider writing a test case for this function:
However, if you ran that test you would find that the createUser
function would fail, throwing the error: TypeError: response.text is not a function
. This is because the Response
class you've imported from has been mocked (due to the jest.mock
call at the top of the test file) so it no longer behaves the way it should.
This allows your test file to import the actual Response
object from , rather than a mocked version. This means the test will now pass correctly.