NagRock / ts-mockito

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

TypeError: Cannot read property 'add' of undefined #197

Open vladbushev opened 4 years ago

vladbushev commented 4 years ago

I want check what if method service.create runed then method storeService.setType run with null. I have method service.create he return service.createItem$. service.createItem$ return apiService.create$ In unit

when(apiService.create$(TestDataFactory.createData('AAA')))
            .thenReturn(of(TestDataFactory.createData('AAA')));

 when(service.createItem$(TestDataFactory.createData('AAA')))
            .thenReturn(of(TestDataFactory.createData('AAA')));
it('should create', fakeAsync(() => {
            service.create(TestDataFactory.createData('AAA'));

            expect(storeService.setType).toHaveBeenCalledWith(null);
        }));
matyx commented 4 years ago

Can you provide full example? I cant figure out what are you trying to do...