瀏覽代碼

Reuse existing karm config for coverage

Saul Shanabrook 6 年之前
父節點
當前提交
ed769d2e78
共有 1 個文件被更改,包括 16 次插入49 次删除
  1. 16 49
      tests/karma-cov.conf.js

+ 16 - 49
tests/karma-cov.conf.js

@@ -1,53 +1,20 @@
 var path = require('path');
-var webpack = require('./webpack.config');
-
-webpack.module.rules.push(
-  // instrument only testing sources with Istanbul
-  {
-    test: /\.js$/,
-    use: { loader: 'istanbul-instrumenter-loader' },
-    include: process.env.KARMA_COVER_FOLDER
-  }
-);
+var baseConf = require('./karma.conf');
 
 module.exports = function (config) {
-  config.set({
-    basePath: '.',
-    frameworks: ['mocha'],
-    reporters: ['mocha', 'coverage-istanbul'],
-    client: {
-      mocha: {
-        timeout : 10000, // 10 seconds - upped from 2 seconds
-        retries: 3 // Allow for slow server on CI.
-      }
-    },
-    files: [
-      {pattern: path.resolve('./build/injector.js'), watched: false},
-      {pattern: process.env.KARMA_FILE_PATTERN, watched: false}
-    ],
-    preprocessors: {
-      'build/injector.js': ['webpack'],
-      'src/*.spec.ts': ['webpack', 'sourcemap']
-    },
-    mime: {
-      'text/x-typescript': ['ts','tsx']
-    },
-    webpack: webpack,
-    webpackMiddleware: {
-      noInfo: true,
-      stats: 'errors-only'
-    },
-    coverageIstanbulReporter: {
-      reports: ['html', 'text-summary'],
-      dir: path.join('.', 'coverage'),
-      fixWebpackSourcePaths: true
-    },
-    browserNoActivityTimeout: 31000, // 31 seconds - upped from 10 seconds
-    browserDisconnectTimeout: 31000, // 31 seconds - upped from 2 seconds
-    browserDisconnectTolerance: 2,
-    port: 9876,
-    colors: true,
-    singleRun: true,
-    logLevel: config.LOG_INFO
-  });
+  baseConf(config);
+  config.reporters = ['mocha', 'coverage-istanbul'];
+  config.webpack.module.rules.push(
+    // instrument only testing sources with Istanbul
+    {
+      test: /\.js$/,
+      use: { loader: 'istanbul-instrumenter-loader' },
+      include: process.env.KARMA_COVER_FOLDER
+    }
+  );
+  config.coverageIstanbulReporter = {
+    reports: ['html', 'text-summary'],
+    dir: path.join('.', 'coverage'),
+    fixWebpackSourcePaths: true
+  };
 };