blob: 2cb72efbfdc643cdf8633866447aa7e9537c215d [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
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070018viewFiles = viewFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${viewDir}${f}`);
19
20vendorFiles = 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 -070021
Matteo Scandolo23254d12016-04-20 16:50:29 -070022/*eslint-disable*/
Matteo Scandolo23254d12016-04-20 16:50:29 -070023
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070024var files = [
Matteo Scandolo23254d12016-04-20 16:50:29 -070025 'node_modules/babel-polyfill/dist/polyfill.js',
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070026
27
28 // loading jquery (it's used in tests)
29 `./bower_components/jquery/dist/jquery.js`,
30 `./bower_components/jasmine-jquery/lib/jasmine-jquery.js`,
31
32 // loading helpers and vendors
33 `../../xos/core/xoslib/static/js/vendor/ngXosVendor.js`,
34 `../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js`,
35
36 // loading ngMock
37 'template.module.js',
38 `./bower_components/angular-mocks/angular-mocks.js`,
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070039]
40.concat(vendorFiles)
41.concat(viewFiles)
42.concat([
43 // loading tests
Matteo Scandolo3dfbced2016-06-15 16:42:12 -070044 `xosHelpers/spec/test_helpers.js`,
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070045 `../ngXosViews/*/spec/*.test.js`,
46 `../ngXosViews/*/spec/**/*.mock.js`,
Matteo Scandolo23254d12016-04-20 16:50:29 -070047 'xosHelpers/spec/**/*.test.js'
48]);
49
50module.exports = function(config) {
51/*eslint-enable*/
52 config.set({
53
54 // base path that will be used to resolve all patterns (eg. files, exclude)
55 basePath: '',
56
57
58 // frameworks to use
59 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
60 frameworks: ['jasmine'],
61
62
63 // list of files / patterns to load in the browser
64 files: files,
65
66
67 // list of files to exclude
68 exclude: [
69 ],
70
71
72 // preprocess matching files before serving them to the browser
73 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
74 preprocessors: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070075 '../ngXosViews/**/spec/*.test.js': ['babel'],
76 '../ngXosViews/**/spec/*.mock.js': ['babel'],
77 'xosHelpers/spec/**/*.test.js': ['babel'],
Matteo Scandolo23254d12016-04-20 16:50:29 -070078 },
79
80 babelPreprocessor: {
81 options: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070082 presets: [babelPreset],
Matteo Scandolo23254d12016-04-20 16:50:29 -070083 sourceMap: 'inline'
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070084 }
Matteo Scandolo23254d12016-04-20 16:50:29 -070085 },
86
87 //ngHtml2JsPreprocessor: {
88 // 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)
89 // moduleName: 'templates' // define the template module name
90 //},
91
92 // test results reporter to use
93 // possible values: 'dots', 'progress'
94 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
Matteo Scandolo88b220e2016-06-17 11:57:05 -070095 reporters: ['dots', 'junit', 'coverage'],
Matteo Scandolo23254d12016-04-20 16:50:29 -070096
97 junitReporter: {
98 outputDir: 'test-result',
Matteo Scandolo3fa32c62016-04-20 17:00:01 -070099 useBrowserName: false,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700100 outputFile: 'test-results.xml'
101 },
102
103 coverageReporter: {
Matteo Scandolo3fa32c62016-04-20 17:00:01 -0700104 type: 'cobertura',
105 subdir: '.',
106 dir: 'test-result/'
Matteo Scandolo23254d12016-04-20 16:50:29 -0700107 },
108
109 // web server port
110 port: 9876,
111
112
113 // enable / disable colors in the output (reporters and logs)
114 colors: true,
115
116
117 // level of logging
118 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700119 logLevel: config.LOG_INFO,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700120
121
122 // enable / disable watching file and executing tests whenever any file changes
Matteo Scandolo88b220e2016-06-17 11:57:05 -0700123 autoWatch: false,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700124
125
126 // start these browsers
127 // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700128 browsers: [
129 'PhantomJS',
Matteo Scandolo88b220e2016-06-17 11:57:05 -0700130 //'Chrome'
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700131 ],
Matteo Scandolo23254d12016-04-20 16:50:29 -0700132
133
134 // Continuous Integration mode
135 // if true, Karma captures browsers, runs the tests and exits
136 singleRun: true
137 });
138};