Revert "Jest cypress types"

This commit is contained in:
hydroflame 2021-09-10 00:13:03 -04:00 committed by GitHub
parent 715bc541ec
commit 7e8e9e03fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 375 additions and 388 deletions

31
.github/workflows/deploy.yml vendored Normal file

@ -0,0 +1,31 @@
name: CI
on:
push:
branches: [dev]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Test
run: npm run test
- name: Build
run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .

25
.github/workflows/test.yml vendored Normal file

@ -0,0 +1,25 @@
name: CI
on: [push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Test
run: npm run test

1
.gitignore vendored

@ -8,7 +8,6 @@ Netburner.txt
/test/*.bundle.*
/test/*.css
.cypress
dist-tsc
# editor files
.vscode

@ -123,46 +123,3 @@ rules:
_danielyxie/bitburner_ and the base is _dev_.
- Do not check in any generated files under `doc\`. The documentation is built
automatically by ReadTheDocs.
## Tests
There are a few unit tests written using [jest](https://jestjs.io/), and some browser automation tests using [Cypress](https://www.cypress.io/).
### Unit Tests
Run unit tests with:
```sh
$ npm run test
$ npm run test:watch # to re-run tests on changes
```
Tests go in the `/test` directory.
### Browser Tests
There are full browser automation tests which cover some basic "does it work" functionality.
Run these with:
```sh
$ npm run build
$ npm run cy:test
```
To start up the tests in watch mode (re-run on changes), which will also start up a dev server:
```sh
$ npm run cy:dev
```
## TypeScript Setup
This project uses [Project References](https://www.typescriptlang.org/docs/handbook/project-references.html)
to make sure that jest and Cypress tests only exist within Jest/Cypress code.
To type-check the whole project:
```sh
$ npm run typescript
```

@ -1,7 +0,0 @@
{
"extends": "../tsconfig.base.json",
"include": ["**/*"],
"compilerOptions": {
"types": ["cypress", "@testing-library/cypress"]
}
}

@ -4,6 +4,6 @@ module.exports = {
transform: {
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
},
testMatch: ["**/?(*.)+(test).[jt]s?(x)"],
// testMatch: ["**/?(*.)+(test).[jt]s?(x)"],
testEnvironment: "jsdom",
};

7
package-lock.json generated

@ -5,7 +5,6 @@
"requires": true,
"packages": {
"": {
"name": "bitburner",
"version": "0.52.9",
"hasInstallScript": true,
"license": "SEE LICENSE IN license.txt",
@ -64,7 +63,7 @@
"@types/lodash": "^4.14.168",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"babel-jest": "^27.1.0",
"babel-jest": "^27.0.6",
"babel-loader": "^8.0.5",
"beautify-lint": "^1.0.3",
"benchmark": "^2.1.1",
@ -39259,7 +39258,9 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/mathjax-react/-/mathjax-react-1.0.6.tgz",
"integrity": "sha512-GlkPAhaY0FKc95TMdo33mxNZHb+3xRgfgc3YcnQ0cZxvnM1UaF0o8mRI5y5xIwi3JnioeYuukZJWCbIZkACIVw==",
"requires": {}
"requires": {
"mathjax-full": "^3.0.4"
}
},
"mathml-tag-names": {
"version": "2.1.0",

@ -61,7 +61,7 @@
"@types/lodash": "^4.14.168",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"babel-jest": "^27.1.0",
"babel-jest": "^27.0.6",
"babel-loader": "^8.0.5",
"beautify-lint": "^1.0.3",
"benchmark": "^2.1.1",
@ -137,7 +137,6 @@
"lint": "npm run lint:jsts & npm run lint:style",
"lint:jsts": "eslint --fix . --ext js,jsx,ts,tsx",
"lint:style": "stylelint --fix ./css/*",
"typescript": "tsc --build",
"preinstall": "node ./scripts/engines-check.js",
"test": "jest",
"test:watch": "jest --watch",

File diff suppressed because it is too large Load Diff

@ -2,19 +2,19 @@ import { convertTimeMsToTimeElapsedString } from "../utils/StringHelperFunctions
describe("StringHelperFunctions Tests", function () {
it("transforms strings", () => {
expect(convertTimeMsToTimeElapsedString(1000)).toEqual("1 seconds");
expect(convertTimeMsToTimeElapsedString(5 * 60 * 1000 + 34 * 1000)).toEqual("5 minutes 34 seconds");
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000)).toEqual(
expect(convertTimeMsToTimeElapsedString(1000)).equal("1 seconds");
expect(convertTimeMsToTimeElapsedString(5 * 60 * 1000 + 34 * 1000)).equal("5 minutes 34 seconds");
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000)).equal(
"2 days 5 minutes 34 seconds",
);
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000, true)).toEqual(
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000, true)).equal(
"2 days 5 minutes 34.000 seconds",
);
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000 + 123, true)).toEqual(
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000 + 123, true)).equal(
"2 days 5 minutes 34.123 seconds",
);
expect(convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000 + 123.888, true)).equal(
"2 days 5 minutes 34.123 seconds",
);
expect(
convertTimeMsToTimeElapsedString(2 * 60 * 60 * 24 * 1000 + 5 * 60 * 1000 + 34 * 1000 + 123.888, true),
).toEqual("2 days 5 minutes 34.123 seconds");
});
});

@ -44,12 +44,12 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
it("completes the connect command", () => {
const options = determineAllPossibilitiesForTabCompletion(Player, "connect ", 0);
expect(options).toEqual(["8.8.8.8", "near"]);
expect(options).equal(["8.8.8.8", "near"]);
});
it("completes the buy command", () => {
const options = determineAllPossibilitiesForTabCompletion(Player, "buy ", 0);
expect(options).toEqual([
expect(options).equal([
"BruteSSH.exe",
"FTPCrack.exe",
"relaySMTP.exe",
@ -67,23 +67,23 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
Player.getHomeComputer().messages.push("af.lit");
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
const options1 = determineAllPossibilitiesForTabCompletion(Player, "scp ", 0);
expect(options1).toEqual(["/www/script.js", "af.lit", "note.txt", "www/"]);
expect(options1).equal(["/www/script.js", "af.lit", "note.txt", "www/"]);
const options2 = determineAllPossibilitiesForTabCompletion(Player, "scp note.txt ", 1);
expect(options2).toEqual([Player.getHomeComputer().ip, "home", "8.8.8.8", "near", "4.4.4.4", "far"]);
expect(options2).equal([Player.getHomeComputer().ip, "home", "8.8.8.8", "near", "4.4.4.4", "far"]);
});
it("completes the kill, tail, mem, and check commands", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
for (const command of ["kill", "tail", "mem", "check"]) {
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).toEqual(["/www/script.js", "www/"]);
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).equal(["/www/script.js", "www/"]);
}
});
it("completes the nano commands", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
Player.getHomeComputer().writeToTextFile("note.txt", "oh hai mark");
expect(determineAllPossibilitiesForTabCompletion(Player, "nano ", 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, "nano ", 0)).equal([
"/www/script.js",
"note.txt",
".fconf",
@ -97,7 +97,7 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
Player.getHomeComputer().contracts.push(new CodingContract("linklist.cct"));
Player.getHomeComputer().messages.push(new Message("asl.msg"));
Player.getHomeComputer().messages.push("af.lit");
expect(determineAllPossibilitiesForTabCompletion(Player, "rm ", 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, "rm ", 0)).equal([
"/www/script.js",
"NUKE.exe",
"af.lit",
@ -110,7 +110,7 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
it("completes the run command", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
Player.getHomeComputer().contracts.push(new CodingContract("linklist.cct"));
expect(determineAllPossibilitiesForTabCompletion(Player, "run ", 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, "run ", 0)).equal([
"/www/script.js",
"NUKE.exe",
"linklist.cct",
@ -122,7 +122,7 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
Player.getHomeComputer().writeToTextFile("/www/note.txt", "oh hai mark");
Player.getHomeComputer().messages.push(new Message("asl.msg"));
Player.getHomeComputer().messages.push("af.lit");
expect(determineAllPossibilitiesForTabCompletion(Player, "cat ", 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, "cat ", 0)).equal([
"asl.msg",
"af.lit",
"/www/note.txt",
@ -134,7 +134,7 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
Player.getHomeComputer().writeToTextFile("note.txt", "oh hai mark");
for (const command of ["download", "mv"]) {
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).equal([
"/www/script.js",
"note.txt",
"www/",
@ -144,19 +144,19 @@ describe("determineAllPossibilitiesForTabCompletion", function () {
it("completes the cd command", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
expect(determineAllPossibilitiesForTabCompletion(Player, "cd ", 0)).toEqual(["www/"]);
expect(determineAllPossibilitiesForTabCompletion(Player, "cd ", 0)).equal(["www/"]);
});
it("completes the ls and cd commands", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
for (const command of ["ls", "cd"]) {
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).toEqual(["www/"]);
expect(determineAllPossibilitiesForTabCompletion(Player, `${command} `, 0)).equal(["www/"]);
}
});
it("completes commands starting with ./", () => {
Player.getHomeComputer().writeToScriptFile("/www/script.js", "oh hai mark");
expect(determineAllPossibilitiesForTabCompletion(Player, "run ./", 0)).toEqual([
expect(determineAllPossibilitiesForTabCompletion(Player, "run ./", 0)).equal([
".//www/script.js",
"NUKE.exe",
"./www/",

@ -1,4 +0,0 @@
{
"extends": "../tsconfig.base.json",
"include": ["**/*"]
}

@ -1,12 +0,0 @@
{
"compilerOptions": {
"outDir": "./dist-tsc/",
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es2016", "dom", "es2017.object", "es2019"],
"module": "commonjs",
"target": "es6",
"strict": true
}
}

@ -1,14 +1,15 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.src.json"
},
{
"path": "./test/tsconfig.spec.json"
},
{
"path": "./cypress/tsconfig.json"
}
]
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es2016", "dom", "es2017.object", "es2019"],
"module": "commonjs",
"target": "es6",
"sourceMap": true,
"strict": true,
"types": ["cypress", "@testing-library/cypress"]
},
"exclude": ["node_modules"]
}

@ -1,4 +0,0 @@
{
"extends": "./tsconfig.base.json",
"exclude": ["node_modules", "cypress", "test"]
}