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