blob: 3bd017c43c0690c8ce2c8e564325b3e48dde5d53 [file] [log] [blame]
Matteo Scandolod24b8712016-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 Scandolo983d1522016-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 Scandolod24b8712016-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 Scandolod24b8712016-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 Scandoloe51eaa12016-04-20 17:06:27 -070027
Matteo Scandolo983d1522016-04-20 16:50:29 -070028/*eslint-disable*/
Matteo Scandolo983d1522016-04-20 16:50:29 -070029
Matteo Scandolod24b8712016-05-18 14:06:45 -070030var files = [
Matteo Scandolo983d1522016-04-20 16:50:29 -070031 'node_modules/babel-polyfill/dist/polyfill.js',
Matteo Scandolod24b8712016-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`,
Matteo Scandolod24b8712016-05-18 14:06:45 -070045]
46.concat(vendorFiles)
47.concat(viewFiles)
48.concat([
49 // loading tests
Matteo Scandolo79e86d62016-06-15 16:42:12 -070050 `xosHelpers/spec/test_helpers.js`,
Matteo Scandolod24b8712016-05-18 14:06:45 -070051 `../ngXosViews/*/spec/*.test.js`,
52 `../ngXosViews/*/spec/**/*.mock.js`,
Matteo Scandolo983d1522016-04-20 16:50:29 -070053 'xosHelpers/spec/**/*.test.js'
54]);
55
Matteo Scandolod24b8712016-05-18 14:06:45 -070056
Matteo Scandolo983d1522016-04-20 16:50:29 -070057module.exports = function(config) {
58/*eslint-enable*/
59 config.set({
60
61 // base path that will be used to resolve all patterns (eg. files, exclude)
62 basePath: '',
63
64
65 // frameworks to use
66 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
67 frameworks: ['jasmine'],
68
69
70 // list of files / patterns to load in the browser
71 files: files,
72
73
74 // list of files to exclude
75 exclude: [
76 ],
77
78
79 // preprocess matching files before serving them to the browser
80 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
81 preprocessors: {
Matteo Scandolod24b8712016-05-18 14:06:45 -070082 '../ngXosViews/**/spec/*.test.js': ['babel'],
83 '../ngXosViews/**/spec/*.mock.js': ['babel'],
84 'xosHelpers/spec/**/*.test.js': ['babel'],
Matteo Scandolo983d1522016-04-20 16:50:29 -070085 },
86
87 babelPreprocessor: {
88 options: {
Matteo Scandolod24b8712016-05-18 14:06:45 -070089 presets: [babelPreset],
Matteo Scandolo983d1522016-04-20 16:50:29 -070090 sourceMap: 'inline'
Matteo Scandolod24b8712016-05-18 14:06:45 -070091 }
Matteo Scandolo983d1522016-04-20 16:50:29 -070092 },
93
94 //ngHtml2JsPreprocessor: {
95 // 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)
96 // moduleName: 'templates' // define the template module name
97 //},
98
99 // test results reporter to use
100 // possible values: 'dots', 'progress'
101 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
102 reporters: ['dots', 'junit', 'coverage'],
103
104 junitReporter: {
105 outputDir: 'test-result',
Matteo Scandolo16607d82016-04-20 17:00:01 -0700106 useBrowserName: false,
Matteo Scandolo983d1522016-04-20 16:50:29 -0700107 outputFile: 'test-results.xml'
108 },
109
110 coverageReporter: {
Matteo Scandolo16607d82016-04-20 17:00:01 -0700111 type: 'cobertura',
112 subdir: '.',
113 dir: 'test-result/'
Matteo Scandolo983d1522016-04-20 16:50:29 -0700114 },
115
116 // web server port
117 port: 9876,
118
119
120 // enable / disable colors in the output (reporters and logs)
121 colors: true,
122
123
124 // level of logging
125 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
Matteo Scandolod24b8712016-05-18 14:06:45 -0700126 logLevel: config.LOG_INFO,
Matteo Scandolo983d1522016-04-20 16:50:29 -0700127
128
129 // enable / disable watching file and executing tests whenever any file changes
Matteo Scandolod24b8712016-05-18 14:06:45 -0700130 autoWatch: true,
Matteo Scandolo983d1522016-04-20 16:50:29 -0700131
132
133 // start these browsers
134 // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
Matteo Scandolod24b8712016-05-18 14:06:45 -0700135 browsers: [
136 'PhantomJS',
137 // 'Chrome'
138 ],
Matteo Scandolo983d1522016-04-20 16:50:29 -0700139
140
141 // Continuous Integration mode
142 // if true, Karma captures browsers, runs the tests and exits
143 singleRun: true
144 });
145};