Can't run Karma with Angular 1.4.9 with error

2019-08-26 22:54发布

问题:

When running karma start --single-run

there is an error

 Chrome 62.0.3202 (Linux 0.0.0) ERROR
  Uncaught TypeError: angular.module(...).info is not a function
  at /home/ali/bedopedia/client/node_modules/angular-mocks/angular-mocks.js:80

When I opened anguler-mocks.js there is a function called info and it need angular 1.6 .info({ angularVersion: '1.6.6' })

here is package.json file

"devDependencies": {
    "angular-mocks": "^1.6.0",
    "grunt": "^0.4.5",
    "grunt-jsmeter": "^0.3.1",
    "jasmine-core": "^2.5.2",
    "karma": "^0.13.22",
    "karma-chrome-launcher": "^0.2.3",
    "karma-jasmine": "^0.3.8",
    "karma-spec-reporter": "0.0.26",
    "load-grunt-tasks": "^3.5.0"
  }

回答1:

I solved it by making angular-mocks version the same version of angular I am using.

make it "angular-mocks": "1.4.9", in package.json file