Я застрял с настройкой проекта angularjs. Модульные тесты, такие как использование кармы и жасмина, требуют js. Мой проект не настроен должным образом. Я запутался в test-main.js и karma.config.js и в том, как правильно настроить карму. Я всегда получаю ошибку. уточните пожалуйста как установить и запустить карму
projectname
node_modules
public
FolderName
FolderName
app
folderName
contoller
service
app.js
config,js
assets
css
images
js
vedio
templates
html files
tests
unit
dashboardSpec.js
karma.config.js
test-main.js
favicon.ico
index.html
package.json
server.js
Я определил структуру своего проекта. Пожалуйста, объясните мне, как использовать test.main.js и karma.config.js.
test-main.js -
var tests = [];
//console.log("window.__karma__.files",window.__karma__.files);
for (var file in window.__karma__.files) {
if (/Spec\.js$/.test(file)) {
//console.log("if file",file);
tests.push(file);
}
}
//console.log("tests main karma",tests);
requirejs.config({
// Karma serves files from '/base'
baseUrl: '',
paths: {
},
shim: {
},
// ask Require.js to load these files (all our tests)
deps: tests,
// start test run, once Require.js is done
callback: window.__karma__.start
});
karma.config.js
// Karma configuration
// Generated on Mon Jan 07 2019 13:38:40 GMT+0530 (IST)
module.exports = function(config) {
'use strict';
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', 'requirejs'],
// list of files / patterns to load in the browser
files: [
'test-main.js',
{pattern: '../assets/js/angular.js',included:true},
{pattern:'../assets/js/angular-mocks.js',included:true},
{pattern:'../assets/js/angular-route.js', included:true},
{pattern:'../app/config.js',included:false},
{pattern:'../app/app.js',included:false},
{pattern:'../app/dashboard/controller/dashboardCtrl.js',included:false},
{pattern: 'unit/*.js', included: false},
],
// list of files / patterns 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_DEBUG,
// 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,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}