NagRock / ts-mockito

Mocking library for TypeScript
MIT License
969 stars 93 forks source link

TypeError when using `match` with a string #224

Open mlntdrv opened 2 years ago

mlntdrv commented 2 years ago
import { match, mock, when } from 'ts-mockito';
import { SomeClass } from 'some-class';
import { Observable } from 'rxjs';

const SomeClassMock: SomeClass = mock(SomeClass);

when(SomeClassMock.method<boolean>(match('/x/y/'))).thenReturn(
  new Observable<boolean>()
);

TypeError: Cannot read property 'match' of null at MatchingStringMatcher.match (.../node_modules/ts-mockito/src/matcher/type/MatchingStringMatcher.ts:9:22) at .../node_modules/ts-mockito/src/matcher/ArgsToMatchersValidator.ts:8:76 at Array.every () at ArgsToMatchersValidator.validate (.../node_modules/ts-mockito/src/matcher/ArgsToMatchersValidator.ts:8:25) at ReturnValueMethodStub.isApplicable (.../node_modules/ts-mockito/src/stub/ReturnValueMethodStub.ts:14:31) at .../node_modules/ts-mockito/src/MethodStubCollection.ts:23:59 at Array.some () at MethodStubCollection.hasMatchingInAnyGroup (.../node_modules/ts-mockito/src/MethodStubCollection.ts:23:27) at Mocker.getMethodStub (.../node_modules/ts-mockito/src/Mock.ts:238:38) at Proxy. (.../node_modules/ts-mockito/src/Mock.ts:161:37)