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
I have a small issue where setups are only match to exact number of parameters. So if there are optional parameters the setup is no matched and I need to create additional setups for each parameter count. It would be nice to have anything match an unspecified parameter, or have some other way to specify that it's optional (so you can have optional string, optional number etc).
class A {
method(a: string, b?: string) {
return a + b;
}
}
describe('test', () => {
let a: A;
beforeEach(() => {
a = mock(A);
when(a.method(anything(), anything())).thenReturn('a');
// when(a.method(anything())).thenReturn('a'); <-- this would be needed
});
it('should work', () => {
expect(instance(a).method('x', 'y')).toBe('a'); // ok
expect(instance(a).method('x')).toBe('a'); // null
});
});
The text was updated successfully, but these errors were encountered:
I have a small issue where setups are only match to exact number of parameters. So if there are optional parameters the setup is no matched and I need to create additional setups for each parameter count. It would be nice to have anything match an unspecified parameter, or have some other way to specify that it's optional (so you can have optional string, optional number etc).
The text was updated successfully, but these errors were encountered: