Access rootScope in Karma tests


#1

Hey guys,

I am writing karma test with jasmine.
After injecting my controller with something like $controller(‘controllerName’, { scope: $rootScope.$new() …}) I want to test some objects i am writing on the rootScope if the controller is loaded.

If i save the rootScope or if I inject it in my testcase the values are not on it, feels like I am working on another $rootScope instance or something like that?!

Anyone an idea how to test the ctrl rootscope?

Thanks and greets,

bengtler


#2

Is nobody writing tests? :stuck_out_tongue:


#3

Hey there! Not really a ionic issue, but it does bring up a good point, writing test and all.
Check out this post, it does give some good tips when using $rootScope in your tests


#4

I will give it a try next week.

Thank you.