Skip to content

Commit

Permalink
improve performance of karma
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoschenkel committed Nov 24, 2018
1 parent 4f7fa50 commit 7f9d474
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
22 changes: 15 additions & 7 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@ const webpackConfig = require("./webpack.config.js")({ production: false, karma:
delete webpackConfig.entry;

module.exports = config => {
"use strict";

var configuration = {
client: {
mocha: {
timeout : 5000
}
},
basePath: "",
frameworks: [
"mocha",
"chai",
"sinon",
"sinon-chai",
"es6-shim"
],
files: [
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
{ pattern: "node_modules/phaser-ce/build/phaser.js", include: true },
{ pattern: "./test/**/**/**.test.ts", include: true },
{ pattern: "./test/index.ts", include: true },
{ pattern: '**/*.map', served: true, included: false, watched: true }
],
preprocessors: {
"./**/**/**/**.ts": ["sourcemap"],
"./test/**/**/**.test.ts": ["webpack"]
"./test/index.ts": ["webpack"],
"./**/**/**/**.ts": ["sourcemap"]
},
webpack: webpackConfig,
webpackMiddleware: {
Expand All @@ -40,11 +45,13 @@ module.exports = config => {
"karma-remap-istanbul",
"karma-mocha-reporter",
"karma-mocha",
"karma-chai",
"karma-sinon",
"karma-sinon-chai",
"karma-es6-shim",
"karma-coverage-istanbul-reporter"
],
mime: {
"text/x-typescript": ["ts","tsx"]
},
reporters: (
config.singleRun ?
["dots", "mocha", "coverage-istanbul"] :
Expand All @@ -64,6 +71,7 @@ module.exports = config => {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
concurrency: Infinity,
browsers: [],
browserNoActivityTimeout: 50000
};
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/sinon": "^5.0.7",
"@types/webpack-env": "^1.13.6",
"bluebird": "^3.5.3",
"browserify-versionify": "^1.0.6",
"chai": "^4.2.0",
Expand All @@ -69,14 +70,12 @@
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^3.1.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-es6-shim": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"karma-sinon": "^1.0.5",
"karma-sinon-chai": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-sourcemap-writer": "^0.1.2",
Expand Down
7 changes: 7 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="webpack-env" />

// require all modules ending in ".test.ts" from the
// current directory and all subdirectories
const testsContext = require.context(".", true, /\.test\.ts$/);

testsContext.keys().forEach(testsContext);
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
resolved "https://registry.npmjs.org/@types/sinon/-/sinon-5.0.7.tgz#0d9f89dd0c9988c4f1505a92a3a324ee7bdb18a6"
integrity sha512-opwMHufhUwkn/UUDk35LDbKJpA2VBsZT8WLU8NjayvRLGPxQkN+8XmfC2Xl35MAscBE8469koLLBjaI3XLEIww==

"@types/webpack-env@^1.13.6":
version "1.13.6"
resolved "http://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.13.6.tgz#128d1685a7c34d31ed17010fc87d6a12c1de6976"
integrity sha512-5Th3OsZ4gTRdr9Mho83BQ23cex4sRhOR4XTG+m+cJc0FhtUBK9Vn62hBJ+pnQYnSxoPOsKoAPOx6FcphxBC8ng==

"@webassemblyjs/[email protected]":
version "1.7.11"
resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.11.tgz#b988582cafbb2b095e8b556526f30c90d057cace"
Expand Down Expand Up @@ -3497,11 +3502,6 @@ just-extend@^3.0.0:
resolved "https://registry.npmjs.org/just-extend/-/just-extend-3.0.0.tgz#cee004031eaabf6406da03a7b84e4fe9d78ef288"
integrity sha512-Fu3T6pKBuxjWT/p4DkqGHFRsysc8OauWr4ZRTY9dIx07Y9O0RkoR5jcv28aeD1vuAwhm3nLkDurwLXoALp4DpQ==

karma-chai@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz#bee5ad40400517811ae34bb945f762909108b79a"
integrity sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=

karma-chrome-launcher@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz#cf1b9d07136cc18fe239327d24654c3dbc368acf"
Expand Down Expand Up @@ -3555,11 +3555,6 @@ karma-sinon-chai@^2.0.2:
resolved "https://registry.npmjs.org/karma-sinon-chai/-/karma-sinon-chai-2.0.2.tgz#e28c109b989973abafc28a7c9f09ef24a05e07c2"
integrity sha512-SDgh6V0CUd+7ruL1d3yG6lFzmJNGRNQuEuCYXLaorruNP9nwQfA7hpsp4clx4CbOo5Gsajh3qUOT7CrVStUKMw==

karma-sinon@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/karma-sinon/-/karma-sinon-1.0.5.tgz#4e3443f2830fdecff624d3747163f1217daa2a9a"
integrity sha1-TjRD8oMP3s/2JNN0cWPxIX2qKpo=

karma-sourcemap-loader@^0.3.7:
version "0.3.7"
resolved "https://registry.npmjs.org/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8"
Expand Down

0 comments on commit 7f9d474

Please sign in to comment.