blob: a0a1c78e015eaba582e6528181d3577968249129 [file] [log] [blame]
Matteo Scandolo54bc5f72016-05-18 14:06:45 -07001'use strict';
2
3// THIS KARMA CONF WILL ITERATE THE VIEW FOLDER AND PERFORM ALL THE TESTS!!!
4
Matteo Scandolo23254d12016-04-20 16:50:29 -07005// Karma configuration
6// Generated on Tue Oct 06 2015 09:27:10 GMT+0000 (UTC)
7
8/* eslint indent: [2,2], quotes: [2, "single"]*/
9
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070010const babelPreset = require('babel-preset-es2015');
11const fs = require('fs');
12
13const viewDir = '../../xos/core/xoslib/static/js/';
14const vendorDir = '../../xos/core/xoslib/static/js/vendor/';
15let viewFiles = fs.readdirSync(viewDir);
16let vendorFiles = fs.readdirSync(vendorDir);
17
18// hack to avoid testing backbone implementation (they need to be removed)
19viewFiles = viewFiles
20 .filter(f => f.indexOf('xosAdminSite') === -1)
21 .filter(f => f.indexOf('xosCord') === -1)
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070022 .filter(f => f.indexOf('xosHpc') === -1);
23
24viewFiles = viewFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${viewDir}${f}`);
25
26vendorFiles = vendorFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${vendorDir}${f}`);
Matteo Scandolocd1aceb2016-04-20 17:06:27 -070027
Matteo Scandolo23254d12016-04-20 16:50:29 -070028/*eslint-disable*/
Matteo Scandolo23254d12016-04-20 16:50:29 -070029
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070030var files = [
Matteo Scandolo23254d12016-04-20 16:50:29 -070031 'node_modules/babel-polyfill/dist/polyfill.js',
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070032
33
34 // loading jquery (it's used in tests)
35 `./bower_components/jquery/dist/jquery.js`,
36 `./bower_components/jasmine-jquery/lib/jasmine-jquery.js`,
37
38 // loading helpers and vendors
39 `../../xos/core/xoslib/static/js/vendor/ngXosVendor.js`,
40 `../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js`,
41
42 // loading ngMock
43 'template.module.js',
44 `./bower_components/angular-mocks/angular-mocks.js`,
45
46 // loading templates
47 `../../xos/core/xoslib/dashboards/xosDiagnostic.html`,
48
49]
50.concat(vendorFiles)
51.concat(viewFiles)
52.concat([
53 // loading tests
54 `../ngXosViews/*/spec/*.test.js`,
55 `../ngXosViews/*/spec/**/*.mock.js`,
Matteo Scandolo23254d12016-04-20 16:50:29 -070056 'xosHelpers/spec/**/*.test.js'
57]);
58
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070059
Matteo Scandolo23254d12016-04-20 16:50:29 -070060module.exports = function(config) {
61/*eslint-enable*/
62 config.set({
63
64 // base path that will be used to resolve all patterns (eg. files, exclude)
65 basePath: '',
66
67
68 // frameworks to use
69 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
70 frameworks: ['jasmine'],
71
72
73 // list of files / patterns to load in the browser
74 files: files,
75
76
77 // list of files to exclude
78 exclude: [
79 ],
80
81
82 // preprocess matching files before serving them to the browser
83 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
84 preprocessors: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070085 '../ngXosViews/**/spec/*.test.js': ['babel'],
86 '../ngXosViews/**/spec/*.mock.js': ['babel'],
87 'xosHelpers/spec/**/*.test.js': ['babel'],
Matteo Scandolo23254d12016-04-20 16:50:29 -070088 },
89
90 babelPreprocessor: {
91 options: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070092 presets: [babelPreset],
Matteo Scandolo23254d12016-04-20 16:50:29 -070093 sourceMap: 'inline'
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070094 }
Matteo Scandolo23254d12016-04-20 16:50:29 -070095 },
96
97 //ngHtml2JsPreprocessor: {
98 // stripPrefix: 'src/', //strip the src path from template url (http://stackoverflow.com/questions/22869668/karma-unexpected-request-when-testing-angular-directive-even-with-ng-html2js)
99 // moduleName: 'templates' // define the template module name
100 //},
101
102 // test results reporter to use
103 // possible values: 'dots', 'progress'
104 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
105 reporters: ['dots', 'junit', 'coverage'],
106
107 junitReporter: {
108 outputDir: 'test-result',
Matteo Scandolo3fa32c62016-04-20 17:00:01 -0700109 useBrowserName: false,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700110 outputFile: 'test-results.xml'
111 },
112
113 coverageReporter: {
Matteo Scandolo3fa32c62016-04-20 17:00:01 -0700114 type: 'cobertura',
115 subdir: '.',
116 dir: 'test-result/'
Matteo Scandolo23254d12016-04-20 16:50:29 -0700117 },
118
119 // web server port
120 port: 9876,
121
122
123 // enable / disable colors in the output (reporters and logs)
124 colors: true,
125
126
127 // level of logging
128 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700129 logLevel: config.LOG_INFO,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700130
131
132 // enable / disable watching file and executing tests whenever any file changes
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700133 autoWatch: true,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700134
135
136 // start these browsers
137 // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700138 browsers: [
139 'PhantomJS',
140 // 'Chrome'
141 ],
Matteo Scandolo23254d12016-04-20 16:50:29 -0700142
143
144 // Continuous Integration mode
145 // if true, Karma captures browsers, runs the tests and exits
146 singleRun: true
147 });
148};