Testing service in Angular returns module is not defined

后端 未结 7 1185
借酒劲吻你
借酒劲吻你 2020-12-13 03:11

I am trying to run the default service unit test in my project (Taken from the Angular Seed project on GitHub), but I keep getting the error \"module is not defined\".

7条回答
  •  时光取名叫无心
    2020-12-13 03:33

    We use 'module' without 'angular' in our unit tests and it works fine.

    CoffeeScript:

    describe 'DiscussionServicesSpec', ->
        beforeEach module 'DiscussionServices'
        beforeEach inject ... etc.
    

    which compiles to

    JavaScript:

    describe('DiscussionServices', function() {
        beforeEach(module('DiscussionServices'));
        beforeEach(inject(function ... etc.
    

    The only time I see something like the error you described is if in the testacular.conf.js file the angular-mocks.js file is not listed in the files section before the specs trying to use 'module'. If I put it after my tests in the 'files' list I get

    ReferenceError: Can't find variable: module
    

    (Our tests are being run through PhantomJS)

提交回复
热议问题