|
| 1 | +/* eslint-disable max-len */ |
| 2 | + |
| 3 | +import webpackConfig from './webpack.config.babel'; |
| 4 | + |
| 5 | +export default (config) => { |
| 6 | + const configuration = { |
| 7 | + |
| 8 | + // base path that will be used to resolve all patterns (eg. files, exclude) |
| 9 | + basePath: 'test', |
| 10 | + |
| 11 | + |
| 12 | + // frameworks to use |
| 13 | + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 14 | + frameworks: ['mocha'], |
| 15 | + |
| 16 | + |
| 17 | + // list of files / patterns to load in the browser |
| 18 | + files: [ |
| 19 | + 'index.html', |
| 20 | + 'index.js', |
| 21 | + ], |
| 22 | + |
| 23 | + |
| 24 | + // list of files to exclude |
| 25 | + exclude: [ |
| 26 | + ], |
| 27 | + |
| 28 | + |
| 29 | + // preprocess matching files before serving them to the browser |
| 30 | + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor |
| 31 | + preprocessors: { |
| 32 | + 'index.js': ['webpack'], |
| 33 | + 'index.html': ['html2js'], |
| 34 | + }, |
| 35 | + |
| 36 | + |
| 37 | + webpack: { |
| 38 | + ...webpackConfig, |
| 39 | + entry: { |
| 40 | + index: './src/index.js', |
| 41 | + }, |
| 42 | + }, |
| 43 | + |
| 44 | + webpackMiddleware: { stats: 'errors-only' }, |
| 45 | + |
| 46 | + |
| 47 | + // test results reporter to use |
| 48 | + // possible values: 'dots', 'progress' |
| 49 | + // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 50 | + reporters: ['mocha'], |
| 51 | + |
| 52 | + |
| 53 | + // web server port |
| 54 | + port: 9876, |
| 55 | + |
| 56 | + |
| 57 | + // enable / disable colors in the output (reporters and logs) |
| 58 | + colors: true, |
| 59 | + |
| 60 | + |
| 61 | + // level of logging |
| 62 | + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG |
| 63 | + logLevel: config.LOG_ERROR, |
| 64 | + |
| 65 | + |
| 66 | + // enable / disable watching file and executing tests whenever any file changes |
| 67 | + autoWatch: true, |
| 68 | + |
| 69 | + |
| 70 | + // start these browsers |
| 71 | + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher |
| 72 | + browsers: ['Chrome'], |
| 73 | + |
| 74 | + customLaunchers: { |
| 75 | + Chrome_travis_ci: { |
| 76 | + base: 'Chrome', |
| 77 | + flags: ['--no-sandbox'] |
| 78 | + } |
| 79 | + }, |
| 80 | + |
| 81 | + |
| 82 | + // Continuous Integration mode |
| 83 | + // if true, Karma captures browsers, runs the tests and exits |
| 84 | + // singleRun: true, |
| 85 | + |
| 86 | + // Concurrency level |
| 87 | + // how many browser should be started simultaneous |
| 88 | + concurrency: Infinity |
| 89 | + }; |
| 90 | + |
| 91 | + if (process.env.TRAVIS) { |
| 92 | + configuration.browsers = ['Chrome_travis_ci']; |
| 93 | + } |
| 94 | + |
| 95 | + config.set(configuration); |
| 96 | +}; |
0 commit comments