我正在为Jasmine的控制器编写测试; 控制器依赖于我注入的服务beforeEach(inject).但是,当我试图窥探服务中的方法时,我总是会收到以下错误:
spyOn could not find an object to spy upon for replacePod()
Run Code Online (Sandbox Code Playgroud)
我的测试代码如下:
describe('Controller: ResultsController', function () {
'use strict';
var ctrl;
var ResultsService;
var RouteService;
var PodService;
var $scope;
var httpMock;
var log;
// load the controller's module
beforeEach(module('waApp'));·
// Initialize the controller and a mock scope
····
beforeEach(inject(function(
$rootScope,
$log,
$controller,
$httpBackend,
ResultsService,
RouteService,
PodService
) {
$scope = $rootScope.$new();
log = $log;
log.reset();
httpMock = $httpBackend;
ctrl = $controller('ResultsController', {
$scope: $scope,
ResultsService: ResultsService, …Run Code Online (Sandbox Code Playgroud)