我正在使用Karma和茉莉花进行UI单元测试。我设置了所有必需的依赖项。当我开始调试测试用例失败并给出
时无法读取null的属性“替换”
在debug.js中给出警告,但是我没有使用任何debug.js文件。
屏幕截图:
package.js
{
"name": "test-app",
"version": "1.0.0",
"description": "a tool to aid",
"main": "index.html",
"private": true,
"scripts": {
"dev": "gulp dev",
"prod": "gulp prod"
},
"author": "kim",
"license": "Myange Inc.",
"devDependencies": {
"event-stream": "~3.3.1",
"gulp": "^3.9.0",
"gulp-angular-templatecache": "^1.7.0",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-connect": "^2.2.0",
"gulp-maven-deploy": "^1.0.1",
"gulp-ng-annotate": "^1.0.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.8",
"gulp-zip": "^4.0.0",
"jasmine": "^3.1.0",
"karma": "^2.0.5",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.2.0",
"karma-ng-html2js-preprocessor": "^1.0.0",
"lodash": "^4.0.0",
"webdriver-manager": "10.2.5"
},
"dependencies": {
"angular-mocks": "^1.7.2"
}
}
UnitTestCase.js
describe('app.way-bus of test ', function() {
// beforeEach(angular.mock.module('app'));
var $controller, $rootScope;
var DTOptionsBuilder, DTColumnDefBuilder, $http, $q, $compile, Notifier, $location, $sce, $filter, FRh, Rh, RhAuth, $stateParams, $state;
beforeEach(angular.mock.module('restheart'));
beforeEach(angular.mock.module('app.cargo-watchListMgmt', function($provide) {
mockedFactory = {
save: jasmine.createSpy()
};
Notifier = $provide.value('Notifier', mockedFactory);
}));
beforeEach(inject(function(_$controller_, _$rootScope_,_Rh_,_$stateParams_,_$state_,_Notifier_){
// The injector unwraps the underscores (_) from around the parameter names when matching
$controller = _$controller_;
$rootScope = _$rootScope_;
console.log($rootScope)
Rh = _Rh_;
//RhAuth = _RhAuth_;
$stateParams = _$stateParams_;
$state = _$state_;
Notifier = _Notifier_;
}));
describe('call fetchData', function() {
it('check', function() {
var $scope = $rootScope.$new();
console.log($scope)
var controller = $controller('wayBusCntrl', {
$scope: $scope,
Rh: Rh,
//RhAuth: RhAuth,
$stateParams: $stateParams,
$state: $state,
Notifier: Notifier
});
expect($scope.xyz).toBe('satya')
});
});
});
因此,由于该错误,我无法处理我的单元测试(无法读取null的属性“ replace”)。