버전 각카르마 각도 1.5 오류 : alertify.dialog : 최소 두 가지 테스트를 실행
때 이름이 이미 존재합니다 1.5.0
alertify-JS : 1.6.1
나는 것 Angular 1.5 구성 요소에 대한 단위 테스트를 구현하는 것과 같습니다. 여기
//jshint strict: false
module.exports = function(config) {
config.set({
basePath: './',
files: [
'app/bower_components/jquery/dist/jquery.js',
'app/bower_components/angular/angular.js',
'app/bower_components/angular-ui-router/release/angular-ui-router.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/bower_components/kendo-ui/src/js/kendo.ui.core.js',
'app/bower_components/kendo-ui/src/js/kendo.angular.js',
'app/bower_components/kendo-ui/src/js/cultures/kendo.culture.fr-FR.js',
'app/bower_components/alertify-js/build/alertify.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/bower_components/ui-leaflet/dist/ui-leaflet.js',
'app/bower_components/angular-simple-logger/dist/angular-simple-logger.js',
'app/bower_components/lodash/lodash.js',
'app/bower_components/moment/moment.js',
'app/bower_components/moment/locale/fr.js',
'app/modules/app.js',
'app/modules/**/*.md.js',
'app/modules/**/*.js',
'test/**/*.js'
],
autoWatch: false,
frameworks: ['jasmine'],
browsers: ['Chrome'],
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine',
'karma-junit-reporter'
],
singleRun: true,
reporters: ['dots', 'junit'],
junitReporter: {
outputFile: 'test-results.xml'
}
});
};
오류 파일을 재생하는 테스트 케이스의 최소한의 작업 exemple입니다 :
나는 나의
karma.conf.js
가져 오기 내 종속성을 만들었습니다. 두 가지 테스트가 필요합니다.
'use strict';
describe('Component: sales', function() {
var $componentController;
var $scope;
beforeEach(module('app.sales'));
beforeEach(inject(function (_$componentController_, $rootScope, _TownshipService_, $q) {
$scope = $rootScope.$new();
$componentController = _$componentController_('sales', {$scope: $scope, TownshipService: _TownshipService_});
}));
describe('controller', function() {
it('should be defined', function() {
expect($componentController).toBeDefined();
});
it('should not crash', function() {
});
});
});
경고 때문에 충돌하고 있습니다. 우리가 auxConfirm
이라고 부른 We created a new dialog following the default usage of the documentation.
(function (app) {
'use strict';
app.run(function() {
alertify.dialog('auxConfirm', function() {
// [...]
});
});
})(angular.module('app.component'));
우리는 다음과 같은 오류 메시지가 얻을 : 그것은 새로운 사용자 정의 대화 상자를 주입 할 때 alertify 소스 코드에 보면
Chrome 55.0.2883 (Mac OS X 10.12.2) Component: sales controller FAILED
Error: alertify.dialog: name already exists
at Object.dialog ([project_folder]/ui/app/bower_components/alertify-js/build/alertify.js:2885:27)
at [project_folder]/ui/app/modules/common/component/ThreeButtonsConfirm.js:5:18
at Object.invoke ([project_folder]/ui/app/bower_components/angular/angular.js:4604:19)
at [project_folder]/ui/app/bower_components/angular/angular.js:4412:62
at forEach ([project_folder]/ui/app/bower_components/angular/angular.js:321:20)
at Object.createInjector [as injector] ([project_folder]/ui/app/bower_components/angular/angular.js:4412:3)
at Object.workFn ([project_folder]/ui/app/bower_components/angular-mocks/angular-mocks.js:2799:52)
Chrome 55.0.2883 (Mac OS X 10.12.2): Executed 2 of 2 (1 FAILED) (0.073 secs/0.058 secs)
을, 우리는 사용자 정의 대화 상자의 이름을 확인하고 예외를 발생 이미 존재하는 경우 :
/**
* Dialogs factory
*
* @param {string} Dialog name.
* @param {Function} A Dialog factory function.
* @param {Boolean} Indicates whether to create a singleton or transient dialog.
* @param {String} The name of the base type to inherit from.
*/
dialog: function (name, Factory, transient, base) {
// get request, create a new instance and return it.
if (typeof Factory !== 'function') {
return get_dialog(name);
}
if (this.hasOwnProperty(name)) {
throw new Error('alertify.dialog: name already exists');
}
}
이 오류가 발생하지 않도록하려면 어떻게해야합니까? afterEach()
에 넣을 수 있음을 알리는 사용자 지정 대화 상자를 제거하는 방법을 찾지 못했습니다. 이 문제를 방지하기 위해 alertify.js를 다시 만들 수있는 방법이 있습니까?