|
| 1 | +const webpackConfig = require('./webpack.config'); |
| 2 | +const sauceBrowsers = require('./sauce.browsers'); |
| 3 | + |
| 4 | +module.exports = function (config) { |
| 5 | + // list of files / patterns to load in the browser |
| 6 | + // all dependancies should be traced through here |
| 7 | + var files = ['test/unit.js']; |
| 8 | + |
| 9 | + // preprocess matching files before serving them to the browser |
| 10 | + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor |
| 11 | + // webpack will trace and watch all dependancies |
| 12 | + var preprocessors = { |
| 13 | + 'test/unit.js': [ 'webpack', 'sourcemap' ] |
| 14 | + }; |
| 15 | + |
| 16 | + if (process.argv.indexOf('--perf') > -1) { |
| 17 | + files = [ require.resolve('../benchmark/benchmark.js'), 'test/perf.js' ]; |
| 18 | + preprocessors = { |
| 19 | + 'test/perf.js': [ 'webpack', 'sourcemap' ] |
| 20 | + }; |
| 21 | + } |
| 22 | + |
| 23 | + config.set(Object.assign({ |
| 24 | + // base path that will be used to resolve all patterns (eg. files, exclude) |
| 25 | + // setting to process.cwd will make all paths start in current component directory |
| 26 | + basePath: process.cwd(), |
| 27 | + |
| 28 | + // frameworks to use |
| 29 | + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 30 | + frameworks: [ 'mocha', 'chai', 'sinon-chai' ], |
| 31 | + |
| 32 | + // list of files / patterns to load in the browser |
| 33 | + files: files, |
| 34 | + |
| 35 | + // list of files to exclude |
| 36 | + exclude: [], |
| 37 | + |
| 38 | + // list of preprocessors |
| 39 | + preprocessors: preprocessors, |
| 40 | + |
| 41 | + // karma watches the test entry points |
| 42 | + // (you don't need to specify the entry option) |
| 43 | + // webpack watches dependencies |
| 44 | + webpack: Object.assign({}, webpackConfig, { |
| 45 | + devtool: 'inline-source-map', |
| 46 | + entry: undefined |
| 47 | + }), |
| 48 | + |
| 49 | + // test results reporter to use |
| 50 | + // possible values: 'dots', 'progress' |
| 51 | + // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 52 | + reporters: [ 'progress' ], |
| 53 | + |
| 54 | + // web server port |
| 55 | + port: 9876, |
| 56 | + |
| 57 | + // enable / disable colors in the output (reporters and logs) |
| 58 | + colors: true, |
| 59 | + |
| 60 | + // level of logging |
| 61 | + // possible values: LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG |
| 62 | + logLevel: config.LOG_INFO, |
| 63 | + |
| 64 | + // enable / disable watching file and executing tests whenever any file changes |
| 65 | + autoWatch: true, |
| 66 | + |
| 67 | + // start these browsers |
| 68 | + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher |
| 69 | + browsers: [ 'Chrome', 'Firefox' ], |
| 70 | + |
| 71 | + // Continuous Integration mode |
| 72 | + // if true, Karma captures browsers, runs the tests and exits |
| 73 | + singleRun: false, |
| 74 | + |
| 75 | + // Concurrency level |
| 76 | + // how many browser should be started simultaneous |
| 77 | + concurrency: Infinity |
| 78 | + }, process.argv.indexOf('--saucelabs') === -1 ? {} : { |
| 79 | + sauceLabs: { |
| 80 | + testName: 'Unit Tests', |
| 81 | + recordScreenshots: false, |
| 82 | + connectOptions: { verbose: true } |
| 83 | + }, |
| 84 | + customLaunchers: sauceBrowsers, |
| 85 | + browsers: Object.keys(sauceBrowsers), |
| 86 | + captureTimeout: 120000, |
| 87 | + reporters: [ 'saucelabs', 'dots' ], |
| 88 | + autoWatch: false, |
| 89 | + concurrency: 5, |
| 90 | + client: {} |
| 91 | + })); |
| 92 | +}; |
0 commit comments