NagRock / ts-mockito

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

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

Open michael-mckenna opened 6 years ago

michael-mckenna commented 6 years ago
TypeError: Cannot read property 'add' of undefined 
    at <Jasmine>
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/ts-mockito/lib/MethodStubSetter.js:20:1
    at <Jasmine>
    at MethodStubSetter.push../node_modules/ts-mockito/lib/MethodStubSetter.js.MethodStubSetter.thenReturn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/ts-mockito/lib/MethodStubSetter.js:19:1)
    at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/components/edit-release/edit-release.component.spec.ts:199:37)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:388:1)
    at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:288:1)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:387:1)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:138:1)
    at runInTestZone (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:509:1)
    at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:524:1)

In Unit Test: when(component.validDate()).thenReturn(true);

In Component:

validDate() {
    return new Date(this.release.date) >= new Date();
 }
lordrip commented 5 years ago

Hi @michael-mckenna , sorry for the delay, if this is still relevant to you, could you add more info about it? Like steps to reproduce it?