Which is Jest way for restoring mocked function

Finally I found a workable solution thanks to @nbkhope’s contribution.

So the following code work as expected, i.e. it mocks the code and then it restore the original behavior:

const spy = jest.spyOn(
    fs,
    'writeFile' 
  ).mockImplementation((filePath,data) => {
  ...
})
...
spy.mockRestore()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)