我正在使用AngularJS和业力进行测试。
describe('MyController', function() {
let UNIQUE_ID = 1;
beforeEach(module('ngMaterial'));
inject($mdDialog => {
spyOn($mdDialog, 'confirm').and.callThrough();
spyOn($mdDialog, 'show').and.callThrough();
spyOn($mdDialog, 'title').and.callThrough();
});
beforeEach(
inject(function(
$rootScope, $timeout, $q, myService,) { ...
一切正常。
但是,如果我将它添加到beforeEach内(即使我将$ mdDialog添加为参数),也会出现错误:“错误:: title()方法不存在”。
describe('MyController', function() {
let UNIQUE_ID = 1;
beforeEach(module('ngMaterial'));
inject($mdDialog => {
spyOn($mdDialog, 'confirm').and.callThrough();
spyOn($mdDialog, 'show').and.callThrough();
spyOn($mdDialog, 'title').and.callThrough();
});
beforeEach(
inject(function(
$rootScope, $timeout, $q, $mdDialog, myService,) {
spyOn($mdDialog, 'confirm').and.callThrough();
spyOn($mdDialog, 'show').and.callThrough();
spyOn($mdDialog, 'title').and.callThrough();
....
为什么后一种方法不起作用?