TypeStrong / ts-mockito

Mocking library for TypeScript
MIT License
35 stars 9 forks source link

Instanceof-Operator: (instance(mock(MyClass)) instanceof MyClass) is false. #37

Open Hirschfuchs opened 1 year ago

Hirschfuchs commented 1 year ago

As mentioned in https://github.com/NagRock/ts-mockito/issues/204 it is not possible to use the „instanceof“ operator on an instance of a mock. There are workarounds but the native functionality would be nice.

Example: const mockedInstanceOfMyClass = instance(mock(MyClass)) console.log(mockedInstanceOfMyClass instanceof MyClass) // false, should be true

roypeled commented 4 months ago

Can you provide with a code sample of usage? I want to provide the solution but it depends on the ergonomics of the usage.