Closed jacobg closed 3 years ago
ImportMock.mockClassInPlace()
has now been added to the library. This will give you the same functionality as the original if you are simply mocking functions on classes.
Unfortunately the key functionality behind much of this library is based on the idea of swapping the original export with a mock export at the point the file is exported. This new Typescript change blocks that behaviour by ensuring all exports are only gettable
so there is no way to set them during runtime.
If mockClassInPlace()
doesn't solve your problem, you can look into running an older version of Typescript, or changing the way your project is compiled to avoid this Typescript issue.
Since typescript version 3.9, mocking imports is no longer supported as-is, due to this commit: https://github.com/microsoft/TypeScript/pull/32264
There is discussion on this issue regarding sinon mocking also broken by this commit: https://github.com/microsoft/TypeScript/issues/38568
It's a bit tldr; for me. Do you have any ideas for a workaround?