blob: 0726edd23f1728bc3de58f800ef94adda255271a [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)
Matteo Scandolo6467f652016-06-16 17:13:10 -070021 .filter(f => f.indexOf('xosCord') === -1);
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070022
23viewFiles = viewFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${viewDir}${f}`);
24
25vendorFiles = 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 -070026
Matteo Scandolo23254d12016-04-20 16:50:29 -070027/*eslint-disable*/
Matteo Scandolo23254d12016-04-20 16:50:29 -070028
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070029var files = [
Matteo Scandolo23254d12016-04-20 16:50:29 -070030 'node_modules/babel-polyfill/dist/polyfill.js',
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070031
32
33 // loading jquery (it's used in tests)
34 `./bower_components/jquery/dist/jquery.js`,
35 `./bower_components/jasmine-jquery/lib/jasmine-jquery.js`,
36
37 // loading helpers and vendors
38 `../../xos/core/xoslib/static/js/vendor/ngXosVendor.js`,
39 `../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js`,
40
41 // loading ngMock
42 'template.module.js',
43 `./bower_components/angular-mocks/angular-mocks.js`,
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070044]
45.concat(vendorFiles)
46.concat(viewFiles)
47.concat([
48 // loading tests
Matteo Scandolo3dfbced2016-06-15 16:42:12 -070049 `xosHelpers/spec/test_helpers.js`,
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070050 `../ngXosViews/*/spec/*.test.js`,
51 `../ngXosViews/*/spec/**/*.mock.js`,
Matteo Scandolo23254d12016-04-20 16:50:29 -070052 'xosHelpers/spec/**/*.test.js'
53]);
54
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070055
Matteo Scandolo23254d12016-04-20 16:50:29 -070056module.exports = function(config) {
57/*eslint-enable*/
58 config.set({
59
60 // base path that will be used to resolve all patterns (eg. files, exclude)
61 basePath: '',
62
63
64 // frameworks to use
65 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
66 frameworks: ['jasmine'],
67
68
69 // list of files / patterns to load in the browser
70 files: files,
71
72
73 // list of files to exclude
74 exclude: [
75 ],
76
77
78 // preprocess matching files before serving them to the browser
79 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
80 preprocessors: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070081 '../ngXosViews/**/spec/*.test.js': ['babel'],
82 '../ngXosViews/**/spec/*.mock.js': ['babel'],
83 'xosHelpers/spec/**/*.test.js': ['babel'],
Matteo Scandolo23254d12016-04-20 16:50:29 -070084 },
85
86 babelPreprocessor: {
87 options: {
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070088 presets: [babelPreset],
Matteo Scandolo23254d12016-04-20 16:50:29 -070089 sourceMap: 'inline'
Matteo Scandolo54bc5f72016-05-18 14:06:45 -070090 }
Matteo Scandolo23254d12016-04-20 16:50:29 -070091 },
92
93 //ngHtml2JsPreprocessor: {
94 // 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)
95 // moduleName: 'templates' // define the template module name
96 //},
97
98 // test results reporter to use
99 // possible values: 'dots', 'progress'
100 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
Matteo Scandolo6467f652016-06-16 17:13:10 -0700101 reporters: ['dots', 'mocha', 'junit', 'coverage'],
Matteo Scandolo23254d12016-04-20 16:50:29 -0700102
103 junitReporter: {
104 outputDir: 'test-result',
Matteo Scandolo3fa32c62016-04-20 17:00:01 -0700105 useBrowserName: false,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700106 outputFile: 'test-results.xml'
107 },
108
109 coverageReporter: {
Matteo Scandolo3fa32c62016-04-20 17:00:01 -0700110 type: 'cobertura',
111 subdir: '.',
112 dir: 'test-result/'
Matteo Scandolo23254d12016-04-20 16:50:29 -0700113 },
114
115 // web server port
116 port: 9876,
117
118
119 // enable / disable colors in the output (reporters and logs)
120 colors: true,
121
122
123 // level of logging
124 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700125 logLevel: config.LOG_INFO,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700126
127
128 // enable / disable watching file and executing tests whenever any file changes
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700129 autoWatch: true,
Matteo Scandolo23254d12016-04-20 16:50:29 -0700130
131
132 // start these browsers
133 // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
Matteo Scandolo54bc5f72016-05-18 14:06:45 -0700134 browsers: [
135 'PhantomJS',
136 // 'Chrome'
137 ],
Matteo Scandolo23254d12016-04-20 16:50:29 -0700138
139
140 // Continuous Integration mode
141 // if true, Karma captures browsers, runs the tests and exits
142 singleRun: true
143 });
144};