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