You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before using this library I wrote all the mocks myself. Something like...
export class ExampleServiceMock implements Pick<ExampleService, keyof ExampleService> {
method1(_arg: string): Observable<Example> {
throw new Error('ExampleServiceMock.method1 is not mocked');
}
method2(_arg: string): Observable<Example> {
throw new Error('ExampleServiceMock.method2 is not mocked');
}
}
Is it possible to get the mocks to throw a similar Error when the code is calling a method that is not mocked explicitly?
Doing it like this always resulted in a clear error message when forgetting something simple in a test case.
The errors I get now when I forget something is like...
Can't read <field> of undefined
I'm looing for an easy way to get back to this behaviour, without resorting to provide the implementations for all the methods I'm mocking again.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Before using this library I wrote all the mocks myself. Something like...
Is it possible to get the mocks to throw a similar Error when the code is calling a method that is not mocked explicitly?
Doing it like this always resulted in a clear error message when forgetting something simple in a test case.
The errors I get now when I forget something is like...
I'm looing for an easy way to get back to this behaviour, without resorting to provide the implementations for all the methods I'm mocking again.
Beta Was this translation helpful? Give feedback.
All reactions