ReferenceError: module is not defined - Karma/Jasmine configuration with Angular/Laravel app

前端 未结 4 1048

I have an existing Angular/Laravel app in which Laravel acts as an API to the angular frontend serving only JSON data. The page that loads the angular app, index.php

4条回答
  •  情书的邮戳
    2021-02-04 23:58

    I encountered a similar message and turned out I got my angular-mocks file path wrong. I used npm to install angular and angular-mocks, and I specified their path wrongly in my Karma.conf.js like this:

    files: [
        'node_modules/angular/angular.js',
        'node_modules/angular/angular-mocks.js',
        'scripts/*.js',
        'tests/*.js'
    ],
    

    I should specify the path of angular-mocks.js as this:

    'node_modules/angular-mocks/angular-mocks.js'
    

    Very simple error, but could be time-consuming to locate if you just started with AngularJS unit testing and didn't know where to look.

提交回复
热议问题