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