UNPKG

1.8 kBJavaScriptView Raw
1// This is a karma config file. For more details see
2// http://karma-runner.github.io/0.13/config/configuration-file.html
3// we are also using it with karma-webpack
4// https://github.com/webpack/karma-webpack
5
6var path = require('path')
7var merge = require('webpack-merge')
8var baseConfig = require('../../build/webpack.base.conf')
9var utils = require('../../build/utils')
10var webpack = require('webpack')
11var projectRoot = path.resolve(__dirname, '../../')
12
13var webpackConfig = merge(baseConfig, {
14 // use inline sourcemap for karma-sourcemap-loader
15 module: {
16 loaders: utils.styleLoaders()
17 },
18 devtool: '#inline-source-map',
19 vue: {
20 loaders: {
21 js: 'babel-loader'
22 }
23 },
24 plugins: [
25 new webpack.DefinePlugin({
26 'process.env': require('../../config/test.env')
27 })
28 ]
29})
30
31// no need for app entry during tests
32delete webpackConfig.entry
33
34// Use babel for test files too
35webpackConfig.module.loaders.some(function (loader, i) {
36 if (/^babel(-loader)?$/.test(loader.loader)) {
37 loader.include.push(path.resolve(projectRoot, 'test/unit'))
38 return true
39 }
40})
41
42module.exports = function (config) {
43 config.set({
44 // to run in additional browsers:
45 // 1. install corresponding karma launcher
46 // http://karma-runner.github.io/0.13/config/browsers.html
47 // 2. add it to the `browsers` array below.
48 browsers: ['PhantomJS'],
49 frameworks: ['mocha', 'sinon-chai'],
50 reporters: ['spec', 'coverage'],
51 files: ['./index.js'],
52 preprocessors: {
53 './index.js': ['webpack', 'sourcemap']
54 },
55 webpack: webpackConfig,
56 webpackMiddleware: {
57 noInfo: true
58 },
59 coverageReporter: {
60 dir: './coverage',
61 reporters: [
62 { type: 'lcov', subdir: '.' },
63 { type: 'text-summary' }
64 ]
65 }
66 })
67}