mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
Converted mocha unit tests to run using mocha-webpack (mochapack) package
This commit is contained in:
parent
cdb5dfec62
commit
ece246b391
888
package-lock.json
generated
888
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,7 @@
|
||||
"beautify-lint": "^1.0.3",
|
||||
"benchmark": "^2.1.1",
|
||||
"bundle-loader": "~0.5.0",
|
||||
"chai": "^4.2.0",
|
||||
"css-loader": "^0.28.11",
|
||||
"es6-promise-polyfill": "^1.1.1",
|
||||
"eslint": "^4.19.1",
|
||||
@ -64,6 +65,8 @@
|
||||
"lodash": "^4.17.10",
|
||||
"mini-css-extract-plugin": "^0.4.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^6.1.4",
|
||||
"mochapack": "^1.1.1",
|
||||
"node-sass": "^4.10.0",
|
||||
"raw-loader": "~0.5.0",
|
||||
"sass-loader": "^7.0.3",
|
||||
@ -108,6 +111,7 @@
|
||||
"lint:style": "stylelint ./css/*",
|
||||
"lint:typescript": "tslint --project . --exclude **/*.d.ts --format stylish src/**/*.ts utils/**/*.ts",
|
||||
"preinstall": "node ./scripts/engines-check.js",
|
||||
"test": "mochapack --webpack-config webpack.config-test.js ./test/index.js",
|
||||
"watch": "webpack --watch --mode production",
|
||||
"watch:dev": "webpack --watch --mode development"
|
||||
},
|
||||
|
@ -260,7 +260,7 @@ export const RamCosts: IMap<any> = {
|
||||
getStamina: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||
joinBladeburnerFaction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||
joinBladeburnerDivision: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||
getBonusTime: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||
getBonusTime: () => 0,
|
||||
},
|
||||
|
||||
// Coding Contract API
|
||||
@ -327,6 +327,6 @@ export function getRamCost(...args: string[]): number {
|
||||
return curr;
|
||||
}
|
||||
|
||||
console.warn(`Expected type: ${currType}`);
|
||||
console.warn(`Unexpected type (${currType}) for value [${args}]`);
|
||||
return 0;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ import { OrderTypes } from "./StockMarket/data/OrderTypes";
|
||||
import { PositionTypes } from "./StockMarket/data/PositionTypes";
|
||||
import { StockSymbols } from "./StockMarket/data/StockSymbols";
|
||||
import {
|
||||
getStockmarket4SDataCost,
|
||||
getStockMarket4SDataCost,
|
||||
getStockMarket4STixApiCost
|
||||
} from "./StockMarket/StockMarketCosts";
|
||||
import { TextFile, getTextFile, createTextFile } from "./TextFile";
|
||||
|
11
test/Netscript/DynamicRamCalculationTests.js
Normal file
11
test/Netscript/DynamicRamCalculationTests.js
Normal file
@ -0,0 +1,11 @@
|
||||
// TODO Importing NetscriptFunctions breaks the mochapack build
|
||||
// import { NetscriptFunctions } from "../../src/NetscriptFunctions";
|
||||
import { expect } from "chai";
|
||||
|
||||
console.log("Beginning Netscript Dynamic RAM Calculation/Generation Tests");
|
||||
|
||||
describe("Netscript Static RAM Calculation/Generation Tests", function() {
|
||||
it("should run", function() {
|
||||
expect(1).to.equal(1);
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
# Unit Tests
|
||||
This directory contains unit tests for Bitburner.
|
||||
|
||||
Unit tests use Mocha/Chai and are run through the browser. The Mocha/Chai
|
||||
packages are sourced directly in HTML.
|
||||
Unit tests use Mocha/Chai and are run using mochapack (mocha-webpack fork).
|
||||
Run the test command with `npm run test`
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { CONSTANTS } from "../src/Constants";
|
||||
import { Order } from "../src/StockMarket/Order";
|
||||
//import { processOrders } from "../src/StockMarket/OrderProcessing";
|
||||
// import { processOrders } from "../src/StockMarket/OrderProcessing";
|
||||
import { Stock } from "../src/StockMarket/Stock";
|
||||
/*
|
||||
import {
|
||||
deleteStockMarket,
|
||||
initStockMarket,
|
||||
@ -11,7 +10,6 @@ import {
|
||||
StockMarket,
|
||||
SymbolToStockMap,
|
||||
} from "../src/StockMarket/StockMarket";
|
||||
*/
|
||||
import {
|
||||
calculateIncreasingPriceMovement,
|
||||
calculateDecreasingPriceMovement,
|
||||
@ -24,8 +22,9 @@ import {
|
||||
import { OrderTypes } from "../src/StockMarket/data/OrderTypes"
|
||||
import { PositionTypes } from "../src/StockMarket/data/PositionTypes";
|
||||
|
||||
const assert = chai.assert;
|
||||
const expect = chai.expect;
|
||||
//const assert = chai.assert;
|
||||
//const expect = chai.expect;
|
||||
import { expect } from "chai";
|
||||
|
||||
console.log("Beginning Stock Market Tests");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<!-- From https://medium.com/dailyjs/running-mocha-tests-as-native-es6-modules-in-a-browser-882373f2ecb0 -->
|
||||
<!-- NOT CURRENTLY USED. Used to run mocha in browser -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
|
@ -1,2 +1,3 @@
|
||||
// export * from "./Netscript/DynamicRamCalculationTests";
|
||||
export * from "./Netscript/StaticRamCalculationTests";
|
||||
export * from "./StockMarketTests";
|
||||
|
2035
test/tests.bundle.js
2035
test/tests.bundle.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
4889
test/tests.css
4889
test/tests.css
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
96
webpack.config-test.js
Normal file
96
webpack.config-test.js
Normal file
@ -0,0 +1,96 @@
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
const statsConfig = {
|
||||
builtAt: true,
|
||||
children: false,
|
||||
chunks: false,
|
||||
chunkGroups: false,
|
||||
chunkModules: false,
|
||||
chunkOrigins: false,
|
||||
colors: true,
|
||||
entrypoints: true,
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': "\"development\""
|
||||
}),
|
||||
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
|
||||
new webpack.ProvidePlugin({
|
||||
// Automtically detect jQuery and $ as free var in modules
|
||||
// and inject the jquery library
|
||||
// This is required by many jquery plugins
|
||||
jquery: "jquery",
|
||||
jQuery: "jquery",
|
||||
$: "jquery"
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css"
|
||||
})
|
||||
],
|
||||
target: "web",
|
||||
devtool: "source-map",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.(jsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: "babel-loader"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"sass-loader"
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
removeAvailableModules: true,
|
||||
removeEmptyChunks: true,
|
||||
mergeDuplicateChunks: true,
|
||||
flagIncludedChunks: true,
|
||||
occurrenceOrder: true,
|
||||
sideEffects: true,
|
||||
providedExports: true,
|
||||
usedExports: true,
|
||||
concatenateModules: false,
|
||||
namedModules: false,
|
||||
namedChunks: false,
|
||||
minimize: false,
|
||||
portableRecords: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: `tests/vendor`,
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
".tsx",
|
||||
".ts",
|
||||
".js",
|
||||
".jsx",
|
||||
]
|
||||
},
|
||||
stats: statsConfig,
|
||||
};
|
||||
};
|
@ -9,9 +9,6 @@ module.exports = (env, argv) => {
|
||||
const outputDirectory = isDevServer ? "dist-dev" : "dist";
|
||||
const entries = {};
|
||||
entries[`${outputDirectory}/engine`] = "./src/engine.jsx";
|
||||
if (!isDevServer) {
|
||||
entries["test/tests"] = "./test/index.js";
|
||||
}
|
||||
|
||||
const statsConfig = {
|
||||
builtAt: true,
|
||||
@ -73,9 +70,6 @@ module.exports = (env, argv) => {
|
||||
sortClassName: false,
|
||||
useShortDoctype: false
|
||||
},
|
||||
excludeChunks: [
|
||||
"test/tests"
|
||||
]
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css"
|
||||
|
Loading…
Reference in New Issue
Block a user