Switch to jest

This commit is contained in:
Johannes Loher 2021-02-11 13:42:38 +01:00
parent b6bb22dc81
commit af07168c5b
11 changed files with 2534 additions and 8248 deletions

1
.gitignore vendored
View file

@ -17,6 +17,7 @@ dist
# Junit results # Junit results
results.xml results.xml
junit.xml
# yarn # yarn
.yarn/* .yarn/*

View file

@ -29,7 +29,7 @@ test:
when: always when: always
reports: reports:
junit: junit:
- results.xml - junit.xml
build: build:
stage: build stage: build

9
jest.config.js Normal file
View file

@ -0,0 +1,9 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
globals: {
"ts-jest": {
tsconfig: "<rootDir>/spec/tsconfig.spec.json",
},
},
};

8133
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -39,13 +39,13 @@
"updateManifest": "gulp updateManifest", "updateManifest": "gulp updateManifest",
"lint": "eslint 'src/**/*.ts' --cache", "lint": "eslint 'src/**/*.ts' --cache",
"lint:fix": "eslint 'src/**/*.ts' --cache --fix", "lint:fix": "eslint 'src/**/*.ts' --cache --fix",
"test": "ts-node ./node_modules/jasmine/bin/jasmine", "test": "jest",
"test:ci": "ts-node ./node_modules/jasmine-xml-reporter/bin/jasmine --junitreport", "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
"format": "prettier --write 'src/**/*.(ts|json|scss)'" "format": "prettier --write 'src/**/*.(ts|json|scss)'"
}, },
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^9.0.6", "@types/fs-extra": "^9.0.6",
"@types/jasmine": "^3.6.3", "@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.14.2", "@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2", "@typescript-eslint/parser": "^4.14.2",
"archiver": "^5.2.0", "archiver": "^5.2.0",
@ -61,12 +61,13 @@
"gulp-sass": "^4.1.0", "gulp-sass": "^4.1.0",
"gulp-typescript": "^6.0.0-alpha.1", "gulp-typescript": "^6.0.0-alpha.1",
"husky": "^4.3.8", "husky": "^4.3.8",
"jasmine": "^3.6.4", "jest": "^26.6.3",
"jasmine-xml-reporter": "^1.2.1", "jest-junit": "^12.0.0",
"json-stringify-pretty-compact": "^2.0.0", "json-stringify-pretty-compact": "^2.0.0",
"lint-staged": "^10.5.4", "lint-staged": "^10.5.4",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"sass": "^1.32.6", "sass": "^1.32.6",
"ts-jest": "^26.5.1",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"typescript": "^4.1.3", "typescript": "^4.1.3",
"yargs": "^16.2.0" "yargs": "^16.2.0"

View file

@ -1,4 +1,3 @@
import "jasmine";
import * as fs from "fs-extra"; import * as fs from "fs-extra";
import * as path from "path"; import * as path from "path";

View file

@ -1,7 +1,5 @@
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../../src/module/rolls/roll-executor"; import { RollResult, RollResultStatus } from "../../src/module/rolls/roll-data";
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../src/module/rolls/roll-executor";
import "jasmine";
import { RollResult, RollResultStatus } from "../../../src/module/rolls/roll-data";
describe("DS4 Rolls with one die and no modifications.", () => { describe("DS4 Rolls with one die and no modifications.", () => {
it("Should do a regular success roll.", () => { it("Should do a regular success roll.", () => {

View file

@ -1,24 +1,23 @@
import "jasmine"; import { isDiceSwapNecessary } from "../../src/module/rolls/roll-utils";
import { isDiceSwapNecessary } from "../../../src/module/rolls/roll-utils";
describe("Utility function testing if dice swap is necessary", () => { describe("Utility function testing if dice swap is necessary", () => {
it("Should not swap if all dice are crit successes.", () => { it("Should not swap if all dice are crit successes.", () => {
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalse(); expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalsy();
}); });
it("Should not swap if no die is crit success.", () => { it("Should not swap if no die is crit success.", () => {
expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalse(); expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalsy();
}); });
it("Should not swap if all dice are already in use", () => { it("Should not swap if all dice are already in use", () => {
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalse(); expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalsy();
}); });
it("Should not swap if result does not get any better", () => { it("Should not swap if result does not get any better", () => {
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalse(); expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalsy();
}); });
it("Should swap if result does get better", () => { it("Should swap if result does get better", () => {
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTrue(); expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTruthy();
}); });
}); });

View file

@ -1,7 +0,0 @@
{
"spec_dir": "spec",
"spec_files": ["**/*[sS]pec.ts"],
"helpers": ["helpers/**/*.ts"],
"stopSpecOnExpectationFailure": false,
"random": true
}

7
spec/tsconfig.spec.json Normal file
View file

@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["foundry-vtt-types", "jest"]
},
"include": ["src", "./"]
}

2592
yarn.lock

File diff suppressed because it is too large Load diff