node-red / node-red-node-test-helper

A test framework for Node-RED nodes
Apache License 2.0
57 stars 41 forks source link

unloading throws an error if nothing has been loaded before #38

Open tt92 opened 5 years ago

tt92 commented 5 years ago

If you call unload() but haven't called load(...) before, there will be an unhandled exception caused by this._logSpy.restore() (index.js:257), because this._logSpy is undefined.

This might be a rare use-case but to me unloading should be possible even if there is nothing to unload.

Therefore, I suggest to wrap this line into a if(this._logSpy) { ... } or to add some other form of error handling.

Cheers,

TT