Merge pull request #3826 from thelounge/xpaw/mocharc

Upgrade to mocha@7 and remove mochapack
This commit is contained in:
Pavel Djundik 2020-04-11 12:32:45 +03:00 committed by GitHub
commit 8e00e26054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 342 additions and 540 deletions

View File

@ -13,7 +13,7 @@
"homepage": "https://thelounge.chat/",
"scripts": {
"build": "webpack",
"coverage": "run-s test:{client,server} && nyc --nycrc-path=test/.nycrc-report.json report",
"coverage": "run-s test:* && nyc --nycrc-path=test/.nycrc-report.json report",
"dev": "node index start --dev",
"format:prettier": "prettier --write \"**/*.*\"",
"lint:check-eslint": "eslint --print-config .eslintrc.yml | eslint-config-prettier-check",
@ -21,9 +21,8 @@
"lint:prettier": "prettier --list-different \"**/*.*\"",
"lint:stylelint": "stylelint --color \"client/**/*.css\"",
"start": "node index start",
"test": "run-p --aggregate-output --continue-on-error lint:* test:{client,server}",
"test:client": "nyc --nycrc-path=test/.nycrc-mochapack.json mochapack --colors --opts=test/mochapack.opts",
"test:server": "nyc --nycrc-path=test/.nycrc-mocha.json mocha --colors",
"test": "run-p --aggregate-output --continue-on-error lint:* test:*",
"test:mocha": "webpack --config webpack.config-test.js && nyc --nycrc-path=test/.nycrc-mocha.json mocha --colors --config=test/.mocharc.yml",
"watch": "webpack --watch"
},
"keywords": [
@ -92,8 +91,7 @@
"husky": "4.2.5",
"intersection-observer": "0.7.0",
"mini-css-extract-plugin": "0.9.0",
"mocha": "6.2.2",
"mochapack": "1.1.13",
"mocha": "7.1.1",
"mousetrap": "1.6.5",
"normalize.css": "8.0.1",
"npm-run-all": "4.1.5",

8
test/.mocharc.yml Normal file
View File

@ -0,0 +1,8 @@
color: true
check-leaks: true
recursive: true
reporter: dot
interactive: false
spec: "test/**/*.js"
ignore: "test/client/**"
require: "test/fixtures/env"

View File

@ -1,6 +0,0 @@
{
"all": true,
"temp-dir": "./node_modules/.cache/nyc_output",
"include": ["client/"],
"reporter": ["json", "text-summary"]
}

View File

@ -1,5 +0,0 @@
--check-leaks
--recursive
--reporter dot
--require test/fixtures/env
test/{,!(client)/**/}*.js

View File

@ -1,6 +0,0 @@
--check-leaks
--interactive false
--recursive
--reporter dot
--webpack-config webpack.config-test.js
test/client/**/*.js

View File

@ -1,11 +1,24 @@
"use strict";
const webpack = require("webpack");
const fs = require("fs");
const path = require("path");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const config = require("./webpack.config.js");
const testFile = path.resolve(__dirname, "test/public/testclient.js");
if (fs.existsSync(testFile)) {
fs.unlinkSync(testFile);
}
config.target = "node";
config.devtool = "eval";
config.stats = "errors-only";
config.output.path = path.resolve(__dirname, "test/public");
config.entry = {
"testclient.js": [path.resolve(__dirname, "test/client/index.js")],
};
// Add the istanbul plugin to babel-loader options
for (const rule of config.module.rules) {
@ -19,15 +32,18 @@ for (const rule of config.module.rules) {
// - https://github.com/webpack/webpack/issues/6727#issuecomment-372589122
config.optimization.splitChunks = false;
// "Fixes" Critical dependency: the request of a dependency is an expression
config.plugins.push(new webpack.ContextReplacementPlugin(/vue-server-renderer$/));
// Disable plugins like copy files, it is not required
config.plugins = [
new VueLoaderPlugin(),
// Client tests that require Vue may end up requireing socket.io
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/js(\/|\\)socket\.js/,
path.resolve(__dirname, "scripts/noop.js")
)
);
),
// "Fixes" Critical dependency: the request of a dependency is an expression
new webpack.ContextReplacementPlugin(/vue-server-renderer$/),
];
module.exports = config;

819
yarn.lock

File diff suppressed because it is too large Load Diff