blob: fc05c83f8e075a1d76bf33c61fe300edc18e178e [file] [log] [blame]
Matteo Scandolo40bea632016-05-17 16:51:29 -07001'use strict';
2
3// THIS KARMA CONF WILL ITERATE THE VIEW FOLDER AND PERFORM ALL THE TESTS!!!
4
5// 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
10const babelPreset = require('babel-preset-es2015');
11const fs = require('fs');
12
13const viewDir = '../../xos/core/xoslib/static/js/';
14let viewFiles = fs.readdirSync(viewDir);
15
16// hack to avoid testing backbone implementation (they need to be removed)
Matteo Scandolo753520b2016-05-17 17:37:09 -070017viewFiles = viewFiles
18 .filter(f => f.indexOf('xosAdminSite') === -1)
19 .filter(f => f.indexOf('xosCord') === -1)
20 .filter(f => f.indexOf('xosTenant') === -1);
Matteo Scandolo40bea632016-05-17 16:51:29 -070021
22viewFiles = viewFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${viewDir}${f}`);
23
24/*eslint-disable*/
25
26var files = [
27 'node_modules/babel-polyfill/dist/polyfill.js',
28
29 // loading jquery (it's used in tests)
30 `./bower_components/jasmine-jquery/lib/jasmine-jquery.js`,
31 `./bower_components/jquery/dist/jquery.js`,
32
33 // loading helpers and vendors
34 `../../xos/core/xoslib/static/js/vendor/ngXosVendor.js`,
35 `../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js`,
36
37 // loading ngMock
38 `./bower_components/angular-mocks/angular-mocks.js`,
39
40 // loading templates
41 `../../xos/core/xoslib/dashboards/xosDiagnostic.html`,
42
43 // loading files
44 `../ngXosViews/*/spec/*.test.js`
45].concat(viewFiles);
46
47module.exports = function(config) {
48/*eslint-enable*/
49 config.set({
50
51 // base path that will be used to resolve all patterns (eg. files, exclude)
52 basePath: '',
53
54
55 // frameworks to use
56 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
57 frameworks: ['jasmine'],
58
59
60 // list of files / patterns to load in the browser
61 files: files,
62
63
64 // list of files to exclude
65 exclude: [
66 ],
67
68
69 // preprocess matching files before serving them to the browser
70 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
71 preprocessors: {
72 '../ngXosViews/**/spec/*.test.js': ['babel'],
73 },
74
75 babelPreprocessor: {
76 options: {
77 presets: [babelPreset],
78 sourceMap: 'inline'
79 }
80 },
81
82 //ngHtml2JsPreprocessor: {
83 // 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)
84 // moduleName: 'templates' // define the template module name
85 //},
86
87 // test results reporter to use
88 // possible values: 'dots', 'progress'
89 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
90 reporters: ['mocha'],
91
92
93 // web server port
94 port: 9876,
95
96
97 // enable / disable colors in the output (reporters and logs)
98 colors: true,
99
100
101 // level of logging
102 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
103 logLevel: config.LOG_INFO,
104
105
106 // enable / disable watching file and executing tests whenever any file changes
107 autoWatch: true,
108
109
110 // start these browsers
111 // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
112 browsers: [
113 'PhantomJS'
114 ],
115
116
117 // Continuous Integration mode
118 // if true, Karma captures browsers, runs the tests and exits
119 singleRun: false
120 });
121};