chieffancypants / angular-hotkeys

Configuration-centric keyboard shortcuts for your Angular apps.
http://chieffancypants.github.io/angular-hotkeys/
MIT License
1.68k stars 248 forks source link

hotkeys module.run causes injection issue in unit test #229

Open pete-mckinney opened 8 years ago

pete-mckinney commented 8 years ago

After I added angular-hotkeys to my project, I'm having issues in my unit tests. I'm getting the following error message: Error: [$injector:unpr] Unknown provider: $rootElementProvider <- $rootElement <- hotkeys <- hotkeys

This error message seems to indicate that angular-mocks.js hasn't been included yet, but I've checked it, and it has. I can also verify that that the $rootElementProvider is providing its mock element. All these mechanisms seem fine for everything else. However, I now get the error message above when I try to inject hotkeys service into a test.

It seems to be related to the .run that hotkeys calls to ensure that the initialization code gets called. Does this make sense to anyone? It's puzzling for me. I can make my tests run by putting the .run method inside an if statement that tests for !angular.mock, but this seems like an awkward solution.

FrankHald commented 6 years ago

Did you find a solution for this?