use*_*867 3 angularjs angular-mock karma-mocha
这是来自karma.conf.js文件:
module.exports = function (config) {
config.set({
frameworks: ['mocha', 'chai'],
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'public/ng-app/module.js',
'public/ng-app/**/*.js',
'test/ng/**/*.spec.js'
],
...
Run Code Online (Sandbox Code Playgroud)
我试图使用beforeEach函数注入这样:
describe('my.test', function () {
beforeEach(module('app'));
var MyService;
beforeEach(inject(function (_MyService_) {
MyService = _MyService_;
}));
describe('#send', function () {
it('exists', function () {
expect(MyService.save).to.exist;
});
});
});
Run Code Online (Sandbox Code Playgroud)
但是beforeEach(inject(function(...)...);当我尝试运行测试时,部分代码会导致此错误:
PhantomJS 1.9.8 (Windows 8 0.0.0) my.test "before each" hook: workFn for "exists" FAILED
Error: [$injector:modulerr] Failed to instantiate module ng due to:
TypeError: 'undefined' is not an object (evaluating 'Function.prototype.bind.apply')
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚问题是什么.有人有什么想法吗?谢谢.
| 归档时间: |
|
| 查看次数: |
2120 次 |
| 最近记录: |