Skip to content

Commit d490fa9

Browse files
Merge pull request #10 from RobotlegsJS/headless-chrome
Migrate to Headless Chrome and improve performance of Karma
2 parents 5959efc + 51248ec commit d490fa9

File tree

6 files changed

+107
-352
lines changed

6 files changed

+107
-352
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
dist: trusty
2+
addons:
3+
chrome: stable
14
language: node_js
25
node_js:
36
- stable
@@ -14,7 +17,7 @@ before_install:
1417
before_script:
1518
- greenkeeper-lockfile-update
1619
script:
17-
- node_modules/karma/bin/karma start karma.conf.js --single-run
20+
- yarn test
1821
after_script:
1922
- greenkeeper-lockfile-upload
2023
after_success:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Update `karma` setup to generate code coverage report only for `src` folder (see #3).
88

9+
- Migrate to Headless Chrome and improve performance of `karma` (see #10).
10+
911
- Update dev dependencies to latest version.
1012

1113
### [v0.2.0](https://github.com/RobotlegsJS/RobotlegsJS-Phaser-CE-SignalCommandMap/releases/tag/0.2.0) - 2018-08-04

karma.conf.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1+
const puppeteer = require("puppeteer");
2+
13
process.env.TEST = true;
24
process.env.NODE_ENV = "test";
5+
process.env.CHROME_BIN = puppeteer.executablePath();
36

47
const webpackConfig = require("./webpack.config.js")({ production: false, karma: true });
58

69
delete webpackConfig.entry;
710

811
module.exports = config => {
12+
"use strict";
913

1014
var configuration = {
15+
client: {
16+
mocha: {
17+
timeout : 5000
18+
}
19+
},
1120
basePath: "",
1221
frameworks: [
1322
"mocha",
14-
"chai",
15-
"sinon",
23+
"sinon-chai",
1624
"es6-shim"
1725
],
1826
files: [
1927
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
2028
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
2129
{ pattern: "node_modules/phaser-ce/build/phaser.js", include: true },
22-
{ pattern: "./test/**/**/**.test.ts", include: true },
30+
{ pattern: "./test/index.ts", include: true },
2331
{ pattern: '**/*.map', served: true, included: false, watched: true }
2432
],
2533
preprocessors: {
26-
"./**/**/**/**.ts": ["sourcemap"],
27-
"./test/**/**/**.test.ts": ["webpack"]
34+
"./test/index.ts": ["webpack"],
35+
"./**/**/**/**.ts": ["sourcemap"]
2836
},
2937
webpack: webpackConfig,
3038
webpackMiddleware: {
@@ -37,11 +45,13 @@ module.exports = config => {
3745
"karma-remap-istanbul",
3846
"karma-mocha-reporter",
3947
"karma-mocha",
40-
"karma-chai",
41-
"karma-sinon",
48+
"karma-sinon-chai",
4249
"karma-es6-shim",
4350
"karma-coverage-istanbul-reporter"
4451
],
52+
mime: {
53+
"text/x-typescript": ["ts","tsx"]
54+
},
4555
reporters: (
4656
config.singleRun ?
4757
["dots", "mocha", "coverage-istanbul"] :
@@ -61,16 +71,17 @@ module.exports = config => {
6171
colors: true,
6272
logLevel: config.LOG_INFO,
6373
autoWatch: true,
74+
concurrency: Infinity,
6475
browsers: [],
6576
browserNoActivityTimeout: 50000
6677
};
6778

6879
if (process.env.TRAVIS) {
69-
configuration.browsers.push("PhantomJS");
70-
configuration.plugins.push("karma-phantomjs-launcher");
80+
configuration.browsers.push("ChromeHeadless");
81+
configuration.plugins.push("karma-chrome-launcher");
7182
} else {
72-
configuration.browsers.push("PhantomJS");
73-
configuration.plugins.push("karma-phantomjs-launcher");
83+
configuration.browsers.push("ChromeHeadless");
84+
configuration.plugins.push("karma-chrome-launcher");
7485
}
7586

7687
config.set(configuration);

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@types/chai": "^4.1.7",
6060
"@types/mocha": "^5.2.5",
6161
"@types/sinon": "^5.0.7",
62+
"@types/webpack-env": "^1.13.6",
6263
"bluebird": "^3.5.3",
6364
"browserify-versionify": "^1.0.6",
6465
"chai": "^4.2.0",
@@ -69,15 +70,12 @@
6970
"istanbul": "^0.4.5",
7071
"istanbul-instrumenter-loader": "^3.0.1",
7172
"karma": "^3.1.1",
72-
"karma-chai": "^0.1.0",
7373
"karma-chrome-launcher": "^2.2.0",
7474
"karma-coverage-istanbul-reporter": "^2.0.4",
7575
"karma-es6-shim": "^1.0.0",
7676
"karma-mocha": "^1.3.0",
7777
"karma-mocha-reporter": "^2.2.5",
78-
"karma-phantomjs-launcher": "^1.0.4",
7978
"karma-remap-istanbul": "^0.6.0",
80-
"karma-sinon": "^1.0.5",
8179
"karma-sinon-chai": "^2.0.2",
8280
"karma-sourcemap-loader": "^0.3.7",
8381
"karma-sourcemap-writer": "^0.1.2",
@@ -86,6 +84,7 @@
8684
"phaser-ce": "^2.11.1",
8785
"prettier": "^1.15.2",
8886
"publish-please": "^5.4.0",
87+
"puppeteer": "^1.10.0",
8988
"reflect-metadata": "^0.1.12",
9089
"remap-istanbul": "^0.12.0",
9190
"rimraf": "^2.6.2",

test/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="webpack-env" />
2+
3+
// require all modules ending in ".test.ts" from the
4+
// current directory and all subdirectories
5+
const testsContext = require.context(".", true, /\.test\.ts$/);
6+
7+
testsContext.keys().forEach(testsContext);

0 commit comments

Comments
 (0)