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

TypeError: Cannot read property 'running' of undefined #1635

@NickHeiner

Description

@NickHeiner

I'm trying to figure out how to mock out a service. This is what I'm trying:

'use strict';

var expect = chai.expect;

beforeEach(module('myModule'));

angular.module('mocks', []).factory('getPageName', function() {
    return function() {
        return "foo";
    }
});

describe('Foo', function() {
    it('should not crash', function() {
        module('mocks');
    });
});

Is it supposed to work? I get the following error:

Chrome 23.0 (Mac) Foo should not crash FAILED
    TypeError: Cannot read property 'running' of undefined
        at isSpecRunning (path/lib/angular/angular-mocks.js:1626:44)
        at window.module.angular.mock.module (path/lib/angular/angular-mocks.js:1648:12)
        at Context.<anonymous> (path/test/unit/directives/disclaimer.js:17:9)

I don't want to put the module() call in a beforeEach() because some tests need the mocks and others don't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions