wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

Using Angular-ized third party libraries causes issues #23

Open Zenith-One opened 8 years ago

Zenith-One commented 8 years ago

In my case, I'm using lodash. I have an Angular service which wraps the global in a service called '' so that it's obvious what it's supposed to be when you call things on it (e.g. .extend). However, since bard injects my service as a global, it clobbers the library itself, then after the first test, it removes from the global scope. The end result is that only the first test of anything which uses the service passes. The rest error at dependency injection time because the _ factory no longer returns anything.

I have fixed this issue locally in my test helper file by copying over the library to a different variable stored locally, then running a global afterEach which restores it, but such a thing would probably be good to have as a core functionality of bard.

Edited to add that _.extend is a silly example because that functionality is available via angular.extend, but the idea carries for pretty much any global library which you might wrap in an angular service for mocking purposes.

wardbell commented 8 years ago

I'm not following entirely. Please send me a PR that corrects the problem.