zefoy / ngx-dropzone-wrapper

Angular wrapper library for Dropzone
MIT License
174 stars 51 forks source link

Unit test throws errors #23

Closed kaihaase-wd closed 7 years ago

kaihaase-wd commented 7 years ago

Thanks a lot for this nice wrapper. But I'm a little bit in trouble with my unit tests.

The following error occurs in the unit tests of the component that uses the ngx-dropzone-wrapper directive: inline template: 40: 3 caused by: Can not read property 'destroy' of undefined

This error occurs in Angular 2 and in Angular 4.

Maybe you should check if this.dropzone exists before you destroy it in ngOnDestroy.

sconix commented 7 years ago

I added check for the ngDoCheck so that ngOnDestroy is not called if dropzone has not been initialized yet. This should fix your error, if not then let me know. I released 4.0.2 version so please try that.

topa commented 7 years ago

Hi, I'm not sure if this is really related to the original issue here, but I have a strange error spamming my terminal only while running my tests:

ERROR: 'Error during cleanup of component', UploadComponent{store: Store{_isScalar: false, _dispatcher: Dispatcher{_isScalar: ..., observers: ..., closed: ..., isStopped: ...

This error is caused by a component which uses the DropzoneComponent. I couldn't figure out the issue here. At first I thought there is a .destroy() missing, but you've already implemented it.

Do have an idea what I might do wrong?

topa commented 7 years ago
bildschirmfoto 2017-04-05 um 15 28 50

I think that causes the error. Setting runInsideAngular might fix the issue.

sconix commented 7 years ago

I can't say what could be causing that. I will add unit tests at some point so maybe the issue will present itself to me as well and I could fix it if there is something to fix.