Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Error: Unknown provider: e from ngMock #3531

Closed
kpolitowicz opened this issue Aug 9, 2013 · 1 comment
Closed

Error: Unknown provider: e from ngMock #3531

kpolitowicz opened this issue Aug 9, 2013 · 1 comment

Comments

@kpolitowicz
Copy link

Hi,

I'm working with rails + angularjs (1.0.7) and my specs failed at inject() call with the error as in the title (uglifier ofc). After digging into angular codebase I was able to pinpoint the direct cause:

angular.module('ngMock', ['ng']).provider({
  $browser: angular.mock.$BrowserProvider,
  $exceptionHandler: angular.mock.$ExceptionHandlerProvider,
  $log: angular.mock.$LogProvider,
  $httpBackend: angular.mock.$HttpBackendProvider,
  $rootElement: angular.mock.$RootElementProvider
}).config(function($provide) {
  $provide.decorator('$timeout', function($delegate, $browser) {
    $delegate.flush = function() {
      $browser.defer.flush();
    };
    return $delegate;
  });
});

Turns out that rails' mangler does minify $provider, so this helps:

.config(['$provide', function($provide) {...}]);

I'm pretty new to angular, so I'm not sending a patch (on master the code needs the same treatment, I think). Let me know if the change is really needed or I'm just doing something terribly wrong in my specs :)

Edit: a sample spec causing the error in my stack (CoffeeScript):

angular.module("myApplicationModule", []).value("mode", "app").value "version", "v1.0.1"

describe "MyApp", ->

  beforeEach module("myApplicationModule")

  it "should provide a version", inject(['mode', 'version', (mode, version) ->
    expect(version).toEqual "v1.0.1"
  ])
@petebacondarwin
Copy link
Contributor

@kpolitowicz - this is a valid bug. Can you provide a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants