bardjs
bardjs copied to clipboard
Using Angular-ized third party libraries causes issues
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.
I'm not following entirely. Please send me a PR that corrects the problem.