Skip to content

Commit 6a8ddc9

Browse files
Merge pull request #75 from RobotlegsJS/headless-chrome
Migrate to Headless Chrome and improve performance of Karma
2 parents a694470 + 9ae7a59 commit 6a8ddc9

File tree

6 files changed

+1232
-574
lines changed

6 files changed

+1232
-574
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-
- yarn run test
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
@@ -20,6 +20,8 @@
2020

2121
- Update `karma` setup to generate code coverage report only for `src` folder (see #69).
2222

23+
- Migrate to Headless Chrome and improve performance of Karma (see #75).
24+
2325
- Update dev dependencies to latest version.
2426

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

karma.conf.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
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 = {
1115
basePath: "",
1216
frameworks: [
1317
"mocha",
14-
"chai",
15-
"sinon",
18+
"sinon-chai",
1619
"es6-shim"
1720
],
1821
files: [
1922
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
2023
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
21-
{ pattern: "./test/**/**/**.test.ts", include: true },
24+
{ pattern: "./test/index.ts", include: true },
2225
{ pattern: '**/*.map', served: true, included: false, watched: true }
2326
],
2427
preprocessors: {
25-
"./**/**/**/**.ts": ["sourcemap"],
26-
"./test/**/**/**.test.ts": ["webpack"]
28+
"./test/index.ts": ["webpack"],
29+
"./**/**/**/**.ts": ["sourcemap"]
2730
},
2831
webpack: webpackConfig,
2932
webpackMiddleware: {
@@ -36,11 +39,13 @@ module.exports = config => {
3639
"karma-remap-istanbul",
3740
"karma-mocha-reporter",
3841
"karma-mocha",
39-
"karma-chai",
40-
"karma-sinon",
42+
"karma-sinon-chai",
4143
"karma-es6-shim",
4244
"karma-coverage-istanbul-reporter"
4345
],
46+
mime: {
47+
"text/x-typescript": ["ts","tsx"]
48+
},
4449
reporters: (
4550
config.singleRun ?
4651
["dots", "mocha", "coverage-istanbul"] :
@@ -65,11 +70,11 @@ module.exports = config => {
6570
};
6671

6772
if (process.env.TRAVIS) {
68-
configuration.browsers.push("PhantomJS");
69-
configuration.plugins.push("karma-phantomjs-launcher");
73+
configuration.browsers.push("ChromeHeadless");
74+
configuration.plugins.push("karma-chrome-launcher");
7075
} else {
71-
configuration.browsers.push("PhantomJS");
72-
configuration.plugins.push("karma-phantomjs-launcher");
76+
configuration.browsers.push("ChromeHeadless");
77+
configuration.plugins.push("karma-chrome-launcher");
7378
}
7479

7580
config.set(configuration);

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"@types/bluebird": "^3.5.24",
7373
"@types/chai": "^4.1.7",
7474
"@types/mocha": "^5.2.5",
75-
"@types/sinon": "^5.0.6",
75+
"@types/sinon": "^5.0.7",
76+
"@types/webpack-env": "^1.13.6",
7677
"bluebird": "^3.5.3",
7778
"browserify-versionify": "^1.0.6",
7879
"chai": "^4.2.0",
@@ -83,27 +84,25 @@
8384
"istanbul": "^0.4.5",
8485
"istanbul-instrumenter-loader": "^3.0.1",
8586
"karma": "^3.1.1",
86-
"karma-chai": "^0.1.0",
8787
"karma-chrome-launcher": "^2.2.0",
8888
"karma-coverage-istanbul-reporter": "^2.0.4",
8989
"karma-es6-shim": "^1.0.0",
9090
"karma-mocha": "^1.3.0",
9191
"karma-mocha-reporter": "^2.2.5",
92-
"karma-phantomjs-launcher": "^1.0.4",
9392
"karma-remap-istanbul": "^0.6.0",
94-
"karma-sinon": "^1.0.5",
9593
"karma-sinon-chai": "^2.0.2",
9694
"karma-sourcemap-loader": "^0.3.7",
9795
"karma-sourcemap-writer": "^0.1.2",
9896
"karma-webpack": "^3.0.5",
9997
"mocha": "^5.2.0",
10098
"nyc": "^13.1.0",
10199
"prettier": "^1.15.2",
102-
"publish-please": "^5.2.0",
100+
"publish-please": "^5.3.0",
101+
"puppeteer": "^1.10.0",
103102
"reflect-metadata": "^0.1.12",
104103
"remap-istanbul": "^0.12.0",
105104
"rimraf": "^2.6.2",
106-
"sinon": "^5.1.1",
105+
"sinon": "^7.1.1",
107106
"sinon-chai": "^3.2.0",
108107
"source-map-support": "^0.5.9",
109108
"ts-loader": "^5.3.0",

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)