Skip to content

Commit 7e7d791

Browse files
Merge pull request #16 from RobotlegsJS/headless-chrome
Migrate to Headless Chrome and improve performance of Karma
2 parents 670fa6b + 161b7cb commit 7e7d791

File tree

6 files changed

+107
-347
lines changed

6 files changed

+107
-347
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
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

CHANGELOG.md

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

2727
- Improve webpack configuration used to run example project. The `npm start` script will generate hashed files (to avoid browser cache) and open the broswer automatically (see #5).
2828

29+
- Migrate to Headless Chrome and improve performance of Karma (see #16).
30+
2931
- Update dev dependencies to latest version.
3032

3133
### [v0.2.0](https://github.com/RobotlegsJS/RobotlegsJS-CreateJS/releases/tag/0.2.0) - 2018-08-08

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/easeljs/lib/easeljs.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
@@ -62,6 +62,7 @@
6262
"@types/easeljs": "^1.0.0",
6363
"@types/mocha": "^5.2.5",
6464
"@types/sinon": "^5.0.7",
65+
"@types/webpack-env": "^1.13.6",
6566
"bluebird": "^3.5.3",
6667
"browserify-versionify": "^1.0.6",
6768
"chai": "^4.2.0",
@@ -74,15 +75,12 @@
7475
"istanbul": "^0.4.5",
7576
"istanbul-instrumenter-loader": "^3.0.1",
7677
"karma": "^3.1.1",
77-
"karma-chai": "^0.1.0",
7878
"karma-chrome-launcher": "^2.2.0",
7979
"karma-coverage-istanbul-reporter": "^2.0.4",
8080
"karma-es6-shim": "^1.0.0",
8181
"karma-mocha": "^1.3.0",
8282
"karma-mocha-reporter": "^2.2.5",
83-
"karma-phantomjs-launcher": "^1.0.4",
8483
"karma-remap-istanbul": "^0.6.0",
85-
"karma-sinon": "^1.0.5",
8684
"karma-sinon-chai": "^2.0.2",
8785
"karma-sourcemap-loader": "^0.3.7",
8886
"karma-sourcemap-writer": "^0.1.2",
@@ -91,6 +89,7 @@
9189
"open-browser-webpack-plugin": "^0.0.5",
9290
"prettier": "^1.15.2",
9391
"publish-please": "^5.3.0",
92+
"puppeteer": "^1.10.0",
9493
"reflect-metadata": "^0.1.12",
9594
"remap-istanbul": "^0.12.0",
9695
"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)