Error: [$injector:unpr] Unknown provider: $$rAFProvider

2.3k views Asked by At

Using Karma to test Angular getting error:

    Error: [$injector:modulerr] Failed to instantiate module ngMock due to:
    Error: [$injector:unpr] Unknown provider: $$rAFProvider

Angular mock, Angular versions error? I've heard solutions detailing changing of angular-mock version or angular version--which seems like a bad idea since I'd like to test on the same version as the app starts with. Anyone else have an error like this?

2

There are 2 answers

0
sjt003 On BEST ANSWER

This issue was resolved by making sure the rails asset pipeline, which provides the angular-related assets in my case, was correctly serving assets during testing.

1
Saurabh Ahuja On

Please check your angular version.

Your angular version and angular-mock version must be same.

To download angular-mock go the below link and replace the X.Y.Z with your angular version and save it

http://ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-mocks.js

for example my angular version is 1.2.9

This work for me .