Merge pull request #2094 from thelounge/astorije/tests-in-browser

Enable in-browser run of client testing
This commit is contained in:
Jérémie Astori 2018-02-24 13:00:01 -05:00 committed by GitHub
commit bc1a6319a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1633 additions and 41 deletions

View File

@ -12,16 +12,17 @@
},
"homepage": "https://thelounge.chat/",
"scripts": {
"coverage": "rm -rf .nyc_output/ && npm-run-all test:* && nyc --nycrc-path=test/.nycrc-report report",
"start": "node index start",
"start-dev": "npm-run-all --parallel watch start",
"build": "webpack",
"watch": "webpack --watch",
"test": "npm-run-all --aggregate-output --parallel --continue-on-error test:* lint:*",
"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",
"coverage": "rm -rf .nyc_output/ && run-s test:{client,server} && nyc --nycrc-path=test/.nycrc-report report",
"dev": "run-p watch start",
"lint:css": "stylelint --color \"client/**/*.css\"",
"lint:js": "eslint . --report-unused-disable-directives --color",
"lint:css": "stylelint --color \"client/**/*.css\""
"start": "node index start",
"test": "run-p --aggregate-output --continue-on-error lint:* test:{client,server}",
"test:browser": "webpack-dev-server --config=webpack.config-browser.js",
"test:client": "nyc --nycrc-path=test/.nycrc-mocha-webpack mocha-webpack --colors --opts=test/mocha-webpack.opts",
"test:server": "nyc --nycrc-path=test/.nycrc-mocha mocha --colors",
"watch": "webpack --watch"
},
"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