当我用Chutzpah进行测试时,一切正常 但是当我在浏览器中使用Resharper启动它时,我收到以下错误:
TypeError: jasmine.addMatchers is not a function
和PhantomJS:
TypeError: undefined is not a constructor (evaluating 'jasmine.addMatchers(customMatchers)')
找不到这种奇怪的原因。
测试代码:
describe('Directive: alert', function () {
var scope, compile;
var element;
beforeEach(function () {
jasmine.addMatchers(customMatchers); // from jasmine-wu-test-library.js
module('serviceRequestModule');
inject(function ($rootScope, $compile) {
scope = $rootScope.$new();
compile = $compile;
});
element = angular.element(
'<div>' +
'<alert ng-repeat="alert in alerts" type="{{alert.type}}"' +
'close="removeAlert($index)">{{alert.msg}}' +
'</alert>' +
'</div>');
scope.alerts = [
{ msg: 'foo', type: 'success' },
{ msg: 'bar', type: 'error' },
{ msg: 'baz' }
];
});
function createAlerts() {
compile(element)(scope);
scope.$digest();
return element.find('alert');
}
function findCloseButton(index) {
return element.find('.close').eq(index);
}
function findContent(index) {
return element.find('span').eq(index);
}
it('should generate alerts using ng-repeat', function () {
var alerts = createAlerts();
expect(alerts.length).toEqual(3);
});
});