Я новичок в Foundation и angular, но мне удалось настроить проект Foundation-Apps с помощью Foundation-Cli; однако я не могу заставить работать тестовый бегун. Я использую Karma с инфраструктурой тестирования Jasmine, но мне не удалось загрузить угловой модуль. Любая помощь будет оценена по достоинству! Приложение работает нормально, но не работает загрузка ресурсов для проверки с помощью кармы.
Ошибка, которую я получаю:
ReferenceError. module is not defined...
Я предполагаю, что он не может загрузить «приложение», которое является моим угловым приложением. Любая помощь приветствуется.
структура каталогов:
/root
/bower_components
/build
/assets
/components
/templates
index.html
/client
/assets
/templates
index.html
/node_modules
... local packages ...
/test
bower.json
gulpfile.js
karma.conf.js
package.json
test-main.js
приложение.js:
(function () {
'use strict';
angular.module('application', [
'ui.router',
'ngAnimate',
//foundation
'foundation',
'foundation.dynamicRouting',
'foundation.dynamicRouting.animations'
])
.config(config)
.run(run)
config.$inject = ['$urlRouterProvider', '$locationProvider'];
function config($urlProvider, $locationProvider) {
$urlProvider.otherwise('/');
$locationProvider.html5Mode({
enabled: false,
requireBase: false
});
$locationProvider.hashPrefix('!');
}
function run() {
FastClick.attach(document.body);
}
})();
карма.конф:
// Karma configuration
// Generated on Sun Mar 08 2015 18:16:11 GMT-0500 (Central Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.js',
'bower_components/angular-ui-router/release/angular-ui-router.min.js',
'bower_components/angular-animate/angular-animate.min.js',
'bower_components/angular-mocks/angular-mocks.js',
'build/assets/js/app.js',
'client/assets/services/*.js',
'test/unit/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
Моя демонстрационная спецификация:
'use strict';
describe('Sample Test',function(){
it('should know that 2+2=4',function(){
var simpleMath = 2+2;
expect(simpleMath).toBe(4)
})
});
describe("EventService", function(){
beforeEach(angular.mock.module("application"));
var service;
beforeEach(inject(function(eventservice){
service = eventservice;
}));
describe("Events", function(){
it("should return an array of items", function(){
expect(service.events()).toBeDefined();
});
});
});