undefined 不是一个对象(评估'$scope.students.pay')
undefined is not an object (evaluating '$scope.students.pay')
我有这样的测试:
it('calls the stuFun method', function () {
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
下面是我的控制器函数:
$scope.stuFun = function() {
$scope.students.pay = false;
};
为什么我会收到以下错误:
undefined is not an object (evaluating '$scope.students.pay')
解决方法附在下面:
it('calls the stuFun method', function () {
$scope.students = {};
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
现在 运行 它应该可以工作了。
我有这样的测试:
it('calls the stuFun method', function () {
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
下面是我的控制器函数:
$scope.stuFun = function() {
$scope.students.pay = false;
};
为什么我会收到以下错误:
undefined is not an object (evaluating '$scope.students.pay')
解决方法附在下面:
it('calls the stuFun method', function () {
$scope.students = {};
$scope.stuFun();
expect($scope.stuFun).to
.have.been.calledOnce;
expect($scope.students.pay).to.not.equal(null);
assert.isNotTrue($scope.students.pay)
});
现在 运行 它应该可以工作了。