Last fixes to unit test build configuration

This commit is contained in:
danielyxie 2019-05-09 19:51:56 -07:00
parent 74e72854d8
commit db5fdb1fcb
4 changed files with 11 additions and 2 deletions

@ -109,6 +109,7 @@
"start:dev": "webpack-dev-server --progress --env.devServer --mode development", "start:dev": "webpack-dev-server --progress --env.devServer --mode development",
"build": "webpack --mode production", "build": "webpack --mode production",
"build:dev": "webpack --mode development", "build:dev": "webpack --mode development",
"build:test": "webpack --config webpack.config-test.js",
"lint": "npm run lint:typescript & npm run lint:javascript & npm run lint:style", "lint": "npm run lint:typescript & npm run lint:javascript & npm run lint:style",
"lint:javascript": "eslint *.js ./src/**/*.js ./tests/**/*.js ./utils/**/*.js", "lint:javascript": "eslint *.js ./src/**/*.js ./tests/**/*.js ./utils/**/*.js",
"lint:style": "stylelint ./css/*", "lint:style": "stylelint ./css/*",

@ -1,5 +1,5 @@
# Unit Tests # Unit Tests
This directory contains unit tests for Bitburner. This directory contains unit tests for Bitburner.
Unit tests use Mocha/Chai and are run using mochapack (mocha-webpack fork). Unit tests use Mocha/Chai and are run using mochapack (a mocha-webpack fork).
Run the test command with `npm run test` Run the test command with `npm run test`

@ -15,7 +15,7 @@
mocha.setup('bdd'); mocha.setup('bdd');
mocha.checkLeaks(); mocha.checkLeaks();
</script> </script>
<script type="module" src="tests.bundle.js"></script> <script type="module" src="test.bundle.js"></script>
<script class="mocha-exec" type="module"> <script class="mocha-exec" type="module">
console.log("Running Tests"); console.log("Running Tests");
mocha.run(); mocha.run();

@ -1,3 +1,6 @@
/**
* Webpack configuration for building unit tests
*/
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var MiniCssExtractPlugin = require('mini-css-extract-plugin');
@ -30,8 +33,13 @@ module.exports = (env, argv) => {
$: "jquery" $: "jquery"
}), }),
], ],
entry: "./test/index.js",
target: "web", target: "web",
devtool: "source-map", devtool: "source-map",
output: {
path: path.resolve(__dirname, "./"),
filename: "test/test.bundle.js",
},
module: { module: {
rules: [ rules: [
{ {