以下是我的尝试:
$ git clone https://github.com/angular/angular-seed my_project && cd my_project
$ rm -rf app update_angular.js test/e2e/scenarios.js
$ touch test/e2e/scenarios.js
然后我将代码从AngularJS's official ngMock.$httpBackend
docs粘贴到:
'use strict'; // Line 1
function MyController($scope, $http) {...} // Lines 3-22
describe('MyController', function() {...} // Lines 24-87
不幸的是,当我使用config/karma-e2e.conf
运行测试时,我得到了:
ReferenceError: inject is not defined at
http://localhost:9876/base/test/e2e/scenarios.js?1387679134000:31
答案 0 :(得分:1)
inject在angular-mocks文件中定义,仅用于单元测试。如果您正在使用Karma,只需将其添加到文件数组中。
BTW Angular团队正在将其功能测试迁移到基于Selenium的protractor。我会赶上它而不是角度情景测试框架。量角器好多了。