Project

General

Profile

1
var path = require('path');
2

    
3
var webpackConfig = require('./webpack.config');
4

    
5
var ENV = process.env.npm_lifecycle_event;
6
var isTestWatch = ENV === 'test-watch';
7

    
8
module.exports = function (config) {
9
  var _config = {
10

    
11
    // base path that will be used to resolve all patterns (eg. files, exclude)
12
    basePath: '',
13

    
14
    // frameworks to use
15
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
16
    frameworks: ['jasmine'],
17

    
18
    // list of files / patterns to load in the browser
19
    files: [
20
      { pattern: './karma-shim.js', watched: false }
21
    ],
22

    
23
    // list of files to exclude
24
    exclude: [],
25

    
26
    // preprocess matching files before serving them to the browser
27
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
28
    preprocessors: {
29
      './karma-shim.js': ['webpack', 'sourcemap']
30
    },
31

    
32
    webpack: webpackConfig,
33

    
34
    webpackMiddleware: {
35
      // webpack-dev-middleware configuration
36
      // i. e.
37
      stats: 'errors-only'
38
    },
39

    
40
    webpackServer: {
41
      noInfo: true // please don't spam the console when running in karma!
42
    },
43

    
44
    // test results reporter to use
45
    // possible values: 'dots', 'progress', 'mocha'
46
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
47
    reporters: ["mocha"],
48

    
49
    // web server port
50
    port: 9876,
51

    
52
    // enable / disable colors in the output (reporters and logs)
53
    colors: true,
54

    
55
    // level of logging
56
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
57
    logLevel: config.LOG_INFO,
58

    
59
    // enable / disable watching file and executing tests whenever any file changes
60
    autoWatch: false,
61

    
62
    // start these browsers
63
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
64
    browsers: ['Chrome'],
65

    
66
    // Continuous Integration mode
67
    // if true, Karma captures browsers, runs the tests and exits
68
    singleRun: true
69
  };
70

    
71
  if (!isTestWatch) {
72
    _config.reporters.push("coverage");
73

    
74
    _config.coverageReporter = {
75
      dir: 'coverage/',
76
      reporters: [{
77
        type: 'json',
78
        dir: 'coverage',
79
        subdir: 'json',
80
        file: 'coverage-final.json'
81
      }]
82
    };
83
  }
84

    
85
  config.set(_config);
86

    
87
};
(4-4/10)