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

mock $LogProvider is missing debugEnabled method #3165

Closed
wardbell opened this issue Jul 8, 2013 · 1 comment
Closed

mock $LogProvider is missing debugEnabled method #3165

wardbell opened this issue Jul 8, 2013 · 1 comment

Comments

@wardbell
Copy link

wardbell commented Jul 8, 2013

The $LogProvider mock service provider in angular-mock.js is missing the debugEnabled method. If an app module calls this method during configuration, no test will pass.

There is no workaround other than to guard against it by modifying your app.config call, e.g.

if ($logProvider.debugEnabled) {
    $logProvider.debugEnabled(true)
}

You can't get clever in your test. This won't work:

beforeEach(module('app', function ($logProvider) {
    // angular-mocks' $logProvider fake lacks debugEnabled; 'fix' that
    if (!$logProvider.debugEnabled) {
        $logProvider.debugEnabled = angular.noop;
    }
}));

It doesn't work because the 'app' module would already have thrown an "undefined" exception before your test could monkey patch the debugEnabled method in this beforeEach.

The solution is pretty simple ... so I won't bother with a PR :-) . Just add the debugEnabled method to the mock $LogProvider in angular-mocks.js

@pkozlowski-opensource
Copy link
Member

Duplicate of #2343

There is a PR opened for this already, going to be merged soon (provided that the contributor finishes it...):
#2935

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