mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
Swap out mocha/chai for jest
This commit is contained in:
parent
1a8bcf66cc
commit
ab4863e7df
6
.babelrc
6
.babelrc
@ -1,3 +1,7 @@
|
|||||||
{
|
{
|
||||||
"presets": ["@babel/preset-react"]
|
"presets": [
|
||||||
|
"@babel/preset-env",
|
||||||
|
"@babel/preset-react",
|
||||||
|
"@babel/preset-typescript"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
9
jest.config.js
Normal file
9
jest.config.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
setupFiles: ["./jest.setup.js"],
|
||||||
|
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
||||||
|
transform: {
|
||||||
|
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
|
||||||
|
},
|
||||||
|
// testMatch: ["**/?(*.)+(test).[jt]s?(x)"],
|
||||||
|
testEnvironment: "jsdom",
|
||||||
|
};
|
6
jest.setup.js
Normal file
6
jest.setup.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import "regenerator-runtime/runtime";
|
||||||
|
global.$ = require("jquery");
|
||||||
|
global.indexedDb = jest.fn();
|
||||||
|
global.monaco = {
|
||||||
|
editor: jest.fn(),
|
||||||
|
};
|
14804
package-lock.json
generated
14804
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -50,17 +50,19 @@
|
|||||||
"description": "A cyberpunk-themed incremental game",
|
"description": "A cyberpunk-themed incremental game",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.3.4",
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/preset-env": "^7.15.0",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"@types/chai": "^4.1.7",
|
"@babel/preset-typescript": "^7.15.0",
|
||||||
|
"@types/jest": "^27.0.1",
|
||||||
"@types/lodash": "^4.14.168",
|
"@types/lodash": "^4.14.168",
|
||||||
"@types/mocha": "^5.2.7",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
"@typescript-eslint/parser": "^4.22.0",
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
|
"babel-jest": "^27.0.6",
|
||||||
"babel-loader": "^8.0.5",
|
"babel-loader": "^8.0.5",
|
||||||
"beautify-lint": "^1.0.3",
|
"beautify-lint": "^1.0.3",
|
||||||
"benchmark": "^2.1.1",
|
"benchmark": "^2.1.1",
|
||||||
"bundle-loader": "~0.5.0",
|
"bundle-loader": "~0.5.0",
|
||||||
"chai": "^4.2.0",
|
"cross-env": "^7.0.3",
|
||||||
"css-loader": "^0.28.11",
|
"css-loader": "^0.28.11",
|
||||||
"es6-promise-polyfill": "^1.1.1",
|
"es6-promise-polyfill": "^1.1.1",
|
||||||
"eslint": "^7.24.0",
|
"eslint": "^7.24.0",
|
||||||
@ -69,6 +71,7 @@
|
|||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"i18n-webpack-plugin": "^1.0.0",
|
"i18n-webpack-plugin": "^1.0.0",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
|
"jest": "^27.0.6",
|
||||||
"js-beautify": "^1.5.10",
|
"js-beautify": "^1.5.10",
|
||||||
"jsdom": "^15.0.0",
|
"jsdom": "^15.0.0",
|
||||||
"jsdom-global": "^3.0.2",
|
"jsdom-global": "^3.0.2",
|
||||||
@ -78,10 +81,9 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mini-css-extract-plugin": "^0.4.1",
|
"mini-css-extract-plugin": "^0.4.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mocha": "^6.1.4",
|
|
||||||
"mochapack": "^1.1.1",
|
|
||||||
"null-loader": "^1.0.0",
|
"null-loader": "^1.0.0",
|
||||||
"raw-loader": "~0.5.0",
|
"raw-loader": "~0.5.0",
|
||||||
|
"regenerator-runtime": "^0.13.9",
|
||||||
"sass-loader": "^7.0.3",
|
"sass-loader": "^7.0.3",
|
||||||
"script-loader": "~0.7.0",
|
"script-loader": "~0.7.0",
|
||||||
"should": "^11.1.1",
|
"should": "^11.1.1",
|
||||||
@ -124,8 +126,8 @@
|
|||||||
"lint:jsts": "eslint --fix '*.{js,jsx,ts,tsx}' './src/**/*.{js,jsx,ts,tsx}' './test/**/*.{js,jsx,ts,tsx}' './utils/**/*.{js,jsx,ts,tsx}'",
|
"lint:jsts": "eslint --fix '*.{js,jsx,ts,tsx}' './src/**/*.{js,jsx,ts,tsx}' './test/**/*.{js,jsx,ts,tsx}' './utils/**/*.{js,jsx,ts,tsx}'",
|
||||||
"lint:style": "stylelint --fix ./css/*",
|
"lint:style": "stylelint --fix ./css/*",
|
||||||
"preinstall": "node ./scripts/engines-check.js",
|
"preinstall": "node ./scripts/engines-check.js",
|
||||||
"test": "mochapack --webpack-config webpack.config-test.js -r jsdom-global/register ./test/index.js",
|
"test": "jest",
|
||||||
"test:container": "mochapack --webpack-config webpack.config-test.js --slow 2000 --timeout 10000 -r jsdom-global/register ./test/index.js",
|
"test:watch": "jest --watch",
|
||||||
"watch": "webpack --watch --mode production",
|
"watch": "webpack --watch --mode production",
|
||||||
"watch:dev": "webpack --watch --mode development"
|
"watch:dev": "webpack --watch --mode development"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
# 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 (a mocha-webpack fork).
|
Unit tests use jest.
|
||||||
Run the test command with `npm run test`
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
Run tests with: `npm run test`
|
||||||
|
|
||||||
|
To watch for changes: `npm run test:watch`
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<html>
|
|
||||||
<!-- NOT CURRENTLY USED. Used to run mocha in browser -->
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Mocha Tests</title>
|
|
||||||
<link href="https://unpkg.com/mocha@6.1.4/mocha.css" rel="stylesheet" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="mocha"></div>
|
|
||||||
|
|
||||||
<script defer src="https://unpkg.com/chai/chai.js"></script>
|
|
||||||
<script defer src="https://unpkg.com/mocha/mocha.js"></script>
|
|
||||||
|
|
||||||
<script type="module" class="mocha-init">
|
|
||||||
mocha.setup('bdd');
|
|
||||||
mocha.checkLeaks();
|
|
||||||
</script>
|
|
||||||
<script type="module" src="test.bundle.js"></script>
|
|
||||||
<script class="mocha-exec" type="module">
|
|
||||||
console.log("Running Tests");
|
|
||||||
mocha.run();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||||||
export * from "./Netscript/DynamicRamCalculationTests";
|
|
||||||
export * from "./Netscript/StaticRamCalculationTests";
|
|
||||||
export * from "./StockMarketTests";
|
|
||||||
export * from "./StringHelperFunctionsTests";
|
|
||||||
export * from "./Terminal/DirectoryTests";
|
|
Loading…
Reference in New Issue
Block a user