Enable in-browser run of client testing

This gets us one step closer to cross-browser testing 🎉
This commit is contained in:
Jérémie Astori 2017-11-28 02:10:17 -05:00
parent 2dbb150463
commit ecede860ef
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
5 changed files with 1626 additions and 34 deletions

View File

@ -21,7 +21,8 @@
"test:mocha": "nyc --nycrc-path=test/.nycrc-mocha mocha --colors",
"test:mocha-webpack": "nyc --nycrc-path=test/.nycrc-mocha-webpack mocha-webpack --colors --opts=test/mocha-webpack.opts",
"lint:js": "eslint . --report-unused-disable-directives --color",
"lint:css": "stylelint --color \"client/**/*.css\""
"lint:css": "stylelint --color \"client/**/*.css\"",
"start:mocha": "webpack-dev-server --config=webpack.config-browser.js"
},
"keywords": [
"lounge",
@ -80,6 +81,7 @@
"jquery": "3.3.1",
"jquery-ui": "1.12.1",
"mocha": "5.0.1",
"mocha-loader": "1.1.3",
"mocha-webpack": "1.0.1",
"mousetrap": "1.6.1",
"npm-run-all": "4.1.2",
@ -88,6 +90,7 @@
"stylelint": "9.1.1",
"stylelint-config-standard": "18.1.0",
"textcomplete": "0.16.0",
"webpack": "3.11.0"
"webpack": "3.11.0",
"webpack-dev-server": "2.11.1"
}
}

11
test/client/index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tests</title>
</head>
<body>
<script src="/js/bundle.vendor.js"></script>
<script src="/js/bundle.test.js"></script>
</body>
</html>

7
test/client/index.js Normal file
View File

@ -0,0 +1,7 @@
"use strict";
// Recursively load all JS files (test files) in the `js` folder
const context = require.context("./js", true, /.+\.js$/);
context.keys().forEach(context);
module.exports = context;

22
webpack.config-browser.js Normal file
View File

@ -0,0 +1,22 @@
"use strict";
const path = require("path");
const config = require("./webpack.config.js");
config.entry = {
"js/bundle.test.js": `mocha-loader!${path.join(__dirname, "test/client/index.js")}`,
};
// Instrumentation for testing with mocha
config.module.rules.push({
test: /\.js$/,
include: path.join(__dirname, "test/client"),
use: "mocha-loader",
});
// Tell the webserver where to load the HTML reporter file from
config.devServer = {
contentBase: path.join(__dirname, "test/client"),
};
module.exports = config;

1613
yarn.lock

File diff suppressed because it is too large Load Diff