Matteo Scandolo | 54bc5f7 | 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 | 23254d1 | 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 | 54bc5f7 | 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 | |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 18 | viewFiles = viewFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${viewDir}${f}`); |
| 19 | |
| 20 | vendorFiles = vendorFiles.filter(f => f.indexOf('js') >= 0).filter(f => f.match(/^xos[A-Z][a-z]+/)).map(f => `${vendorDir}${f}`); |
Matteo Scandolo | cd1aceb | 2016-04-20 17:06:27 -0700 | [diff] [blame] | 21 | |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 22 | /*eslint-disable*/ |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 23 | |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 24 | var files = [ |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 25 | 'node_modules/babel-polyfill/dist/polyfill.js', |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 26 | |
| 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 Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 39 | ] |
| 40 | .concat(vendorFiles) |
| 41 | .concat(viewFiles) |
| 42 | .concat([ |
| 43 | // loading tests |
Matteo Scandolo | 3dfbced | 2016-06-15 16:42:12 -0700 | [diff] [blame] | 44 | `xosHelpers/spec/test_helpers.js`, |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 45 | `../ngXosViews/*/spec/*.test.js`, |
| 46 | `../ngXosViews/*/spec/**/*.mock.js`, |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 47 | 'xosHelpers/spec/**/*.test.js' |
| 48 | ]); |
| 49 | |
| 50 | module.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 Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 75 | '../ngXosViews/**/spec/*.test.js': ['babel'], |
| 76 | '../ngXosViews/**/spec/*.mock.js': ['babel'], |
| 77 | 'xosHelpers/spec/**/*.test.js': ['babel'], |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 78 | }, |
| 79 | |
| 80 | babelPreprocessor: { |
| 81 | options: { |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 82 | presets: [babelPreset], |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 83 | sourceMap: 'inline' |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 84 | } |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 85 | }, |
| 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 Scandolo | 88b220e | 2016-06-17 11:57:05 -0700 | [diff] [blame] | 95 | reporters: ['dots', 'junit', 'coverage'], |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 96 | |
| 97 | junitReporter: { |
| 98 | outputDir: 'test-result', |
Matteo Scandolo | 3fa32c6 | 2016-04-20 17:00:01 -0700 | [diff] [blame] | 99 | useBrowserName: false, |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 100 | outputFile: 'test-results.xml' |
| 101 | }, |
| 102 | |
| 103 | coverageReporter: { |
Matteo Scandolo | 3fa32c6 | 2016-04-20 17:00:01 -0700 | [diff] [blame] | 104 | type: 'cobertura', |
| 105 | subdir: '.', |
| 106 | dir: 'test-result/' |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 107 | }, |
| 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 Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 119 | logLevel: config.LOG_INFO, |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 120 | |
| 121 | |
| 122 | // enable / disable watching file and executing tests whenever any file changes |
Matteo Scandolo | 88b220e | 2016-06-17 11:57:05 -0700 | [diff] [blame] | 123 | autoWatch: false, |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 124 | |
| 125 | |
| 126 | // start these browsers |
| 127 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 128 | browsers: [ |
| 129 | 'PhantomJS', |
Matteo Scandolo | 88b220e | 2016-06-17 11:57:05 -0700 | [diff] [blame] | 130 | //'Chrome' |
Matteo Scandolo | 54bc5f7 | 2016-05-18 14:06:45 -0700 | [diff] [blame] | 131 | ], |
Matteo Scandolo | 23254d1 | 2016-04-20 16:50:29 -0700 | [diff] [blame] | 132 | |
| 133 | |
| 134 | // Continuous Integration mode |
| 135 | // if true, Karma captures browsers, runs the tests and exits |
| 136 | singleRun: true |
| 137 | }); |
| 138 | }; |