|
| 1 | +process.env.TEST = true; |
| 2 | +process.env.NODE_ENV = "test"; |
| 3 | + |
| 4 | +const webpackConfig = require("./webpack.config.js")({ production: false, karma: true }); |
| 5 | + |
| 6 | +delete webpackConfig.entry; |
| 7 | + |
| 8 | +module.exports = config => { |
| 9 | + |
| 10 | + var configuration = { |
| 11 | + basePath: "", |
| 12 | + frameworks: [ |
| 13 | + "mocha", |
| 14 | + "chai", |
| 15 | + "sinon", |
| 16 | + "es6-shim" |
| 17 | + ], |
| 18 | + files: [ |
| 19 | + { pattern: "node_modules/reflect-metadata/Reflect.js", include: true }, |
| 20 | + { pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true }, |
| 21 | + { pattern: "node_modules/createjs/builds/1.0.0/createjs.js", include: true }, |
| 22 | + { pattern: "./test/**/**/**.test.ts", include: true }, |
| 23 | + { pattern: '**/*.map', served: true, included: false, watched: true } |
| 24 | + ], |
| 25 | + preprocessors: { |
| 26 | + "./**/**/**/**.ts": ["sourcemap"], |
| 27 | + "./test/**/**/**.test.ts": ["webpack"] |
| 28 | + }, |
| 29 | + webpack: webpackConfig, |
| 30 | + webpackMiddleware: { |
| 31 | + noInfo: true |
| 32 | + }, |
| 33 | + plugins: [ |
| 34 | + "karma-webpack", |
| 35 | + "karma-sourcemap-writer", |
| 36 | + "karma-sourcemap-loader", |
| 37 | + "karma-remap-istanbul", |
| 38 | + "karma-mocha-reporter", |
| 39 | + "karma-mocha", |
| 40 | + "karma-chai", |
| 41 | + "karma-sinon", |
| 42 | + "karma-es6-shim", |
| 43 | + "karma-coverage-istanbul-reporter" |
| 44 | + ], |
| 45 | + reporters: ( |
| 46 | + config.singleRun ? |
| 47 | + ["dots", "mocha", "coverage-istanbul"] : |
| 48 | + ["dots", "mocha"] |
| 49 | + ), |
| 50 | + coverageIstanbulReporter: { |
| 51 | + reports: ["html", "lcov", "lcovonly", "text-summary"], |
| 52 | + dir: "coverage", |
| 53 | + fixWebpackSourcePaths: true, |
| 54 | + "report-config": { |
| 55 | + html: { |
| 56 | + subdir: "html-report" |
| 57 | + } |
| 58 | + } |
| 59 | + }, |
| 60 | + port: 9876, |
| 61 | + colors: true, |
| 62 | + logLevel: config.LOG_INFO, |
| 63 | + autoWatch: true, |
| 64 | + browsers: [], |
| 65 | + browserNoActivityTimeout: 50000 |
| 66 | + }; |
| 67 | + |
| 68 | + if (process.env.TRAVIS) { |
| 69 | + configuration.browsers.push("PhantomJS"); |
| 70 | + configuration.plugins.push("karma-phantomjs-launcher"); |
| 71 | + } else { |
| 72 | + configuration.browsers.push("PhantomJS"); |
| 73 | + configuration.plugins.push("karma-phantomjs-launcher"); |
| 74 | + } |
| 75 | + |
| 76 | + config.set(configuration); |
| 77 | +}; |
0 commit comments