У меня есть проект, который содержит:
- Угловой 1.6.10
- Жасмин 3.1.0
- PhantomJS 2.2.1
- Карма2.0.2
Я создаю модульный тест для следующего класса:
'use strict';
angular.module('Core').controller('MainController', function() {
var $this = {
calculateBirthYear: function(age) {
return (2018 - age);
}
};
return $this;
});
Тест js:
describe('Testing AngularJS Test Suite', function() {
var MainController;
beforeEach(module('Core'));
beforeEach(inject( function ($controller) {
MainController = $controller('MainController');
}));
it('should sum correctly the birth date', function() {
console.log('Birth: %o',MainController.calculateBirthYear(18));
expect(MainController.calculateBirthYear(18)).toBe(2000);
});
});
Когда я смотрюлоги, это показывает, что он рассчитывает, но с ошибкой, что я не знаю, как поступить.
LOG: 'Birth: %o', 2000
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\nTypeError: Attempted to assign to readonly property.",
"str": "An error was thrown in afterAll\nTypeError: Attempted to assign to readonly property."
}