test: use vitest instead of jest
This commit is contained in:
parent
7d953d5a50
commit
bb6d22d14a
12 changed files with 530 additions and 2288 deletions
|
@ -14,9 +14,9 @@ module.exports = {
|
|||
browser: true,
|
||||
},
|
||||
|
||||
extends: ["plugin:@typescript-eslint/recommended", "plugin:jest/recommended", "plugin:prettier/recommended"],
|
||||
extends: ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
|
||||
|
||||
plugins: ["@typescript-eslint", "jest"],
|
||||
plugins: ["@typescript-eslint"],
|
||||
|
||||
rules: {
|
||||
// Specify any specific ESLint rules.
|
||||
|
@ -34,8 +34,6 @@ module.exports = {
|
|||
env: {
|
||||
browser: false,
|
||||
},
|
||||
extends: ["plugin:jest/recommended"],
|
||||
plugins: ["jest"],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -12,5 +12,5 @@
|
|||
"importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.count": 120,
|
||||
"importSorter.importStringConfiguration.tabSize": 4,
|
||||
"importSorter.importStringConfiguration.quoteMark": "double",
|
||||
"importSorter.importStringConfiguration.trailingComma": "multiLine"
|
||||
"importSorter.importStringConfiguration.trailingComma": "multiLine",
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
const config = {
|
||||
preset: "ts-jest",
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
tsconfig: "<rootDir>/spec/tsconfig.json",
|
||||
},
|
||||
},
|
||||
setupFiles: ["<rootDir>/spec/setup.ts"],
|
||||
};
|
||||
|
||||
export default config;
|
17
package.json
17
package.json
|
@ -47,10 +47,13 @@
|
|||
"clean:link": "node ./tools/link-package.js --clean",
|
||||
"lint": "eslint --ext .ts,.js,.cjs,.mjs .",
|
||||
"lint:fix": "eslint --ext .ts,.js,.cjs,.mjs --fix .",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:ci": "jest --ci --reporters=default --reporters=jest-junit",
|
||||
"format": "prettier --write \"./**/*.(ts|js|cjs|mjs|json|scss|yml)\"",
|
||||
"test": "run-p test:vitest test:typecheck",
|
||||
"test:vitest": "vitest run",
|
||||
"test:typecheck": "tsc --noEmit --project spec/tsconfig.json",
|
||||
"test:watch": "vitest",
|
||||
"test:ci": "run-p test:ci:vitest test:typecheck",
|
||||
"test:ci:vitest": "vitest run --reporter=default --reporter=junit --outputFile=junit.xml",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck:watch": "tsc --noEmit --watch",
|
||||
"bump-version": "node ./tools/bump-version.js",
|
||||
|
@ -75,19 +78,16 @@
|
|||
"@seald-io/nedb": "3.0.0",
|
||||
"@swc/core": "1.2.241",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/jest": "28.1.7",
|
||||
"@types/node": "16.11.53",
|
||||
"@typescript-eslint/eslint-plugin": "5.34.0",
|
||||
"@typescript-eslint/parser": "5.34.0",
|
||||
"conventional-changelog-cli": "2.2.2",
|
||||
"conventional-changelog-conventionalcommits": "5.0.0",
|
||||
"eslint": "8.22.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-jest": "26.8.7",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"fs-extra": "10.1.0",
|
||||
"husky": "8.0.1",
|
||||
"jest": "28.1.3",
|
||||
"jest-junit": "14.0.0",
|
||||
"lint-staged": "13.0.3",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.7.1",
|
||||
|
@ -98,9 +98,10 @@
|
|||
"rollup-plugin-swc3": "0.3.0",
|
||||
"sass": "1.54.5",
|
||||
"semver": "7.3.7",
|
||||
"ts-jest": "28.0.8",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4",
|
||||
"vite": "3.0.9",
|
||||
"vitest": "0.22.1",
|
||||
"yargs": "17.5.1"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
{
|
||||
"matchPackagePatterns": ["^@pixi"],
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"matchPackageNames": ["@types/node"],
|
||||
"matchUpdateTypes": ["major"],
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import copy from "@guanghechen/rollup-plugin-copy";
|
||||
import livereload from "rollup-plugin-livereload";
|
||||
import styles from "rollup-plugin-styles";
|
||||
import { swc } from "rollup-plugin-swc3";
|
||||
|
||||
import copy from "@guanghechen/rollup-plugin-copy";
|
||||
|
||||
import { distDirectory, name, sourceDirectory } from "./tools/const.js";
|
||||
import { convertJSONToPack } from "./tools/json-pack-tools.js";
|
||||
|
||||
|
@ -41,9 +42,8 @@ const config = {
|
|||
},
|
||||
plugins: [
|
||||
swc({
|
||||
minify: isProduction,
|
||||
jsc: {
|
||||
minify: {
|
||||
minify: isProduction && {
|
||||
sourceMap: true,
|
||||
mangle: {
|
||||
keepClassNames: true,
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { calculateSpellPrice } from "../../../src/item/spell/calculate-spell-price";
|
||||
|
||||
import type { CooldownDuration, DS4SpellDataSourceData } from "../../../src/item/spell/spell-data-source";
|
||||
|
@ -40,6 +42,7 @@ type TestCase = {
|
|||
type CombinedTestCase = {
|
||||
minimumLevels: DS4SpellDataSourceData["minimumLevels"];
|
||||
expected: number | null;
|
||||
description: string;
|
||||
};
|
||||
|
||||
const testCases: Record<keyof DS4SpellDataSourceData["minimumLevels"], TestCase[]> = {
|
||||
|
@ -134,13 +137,16 @@ function buildCombinedTestCases(): CombinedTestCase[] {
|
|||
wizardTestCase.expected ?? Infinity,
|
||||
)
|
||||
: null;
|
||||
const minimumLevels = {
|
||||
healer: healerTestCase.minimumLevel,
|
||||
sorcerer: sorcererTestCase.minimumLevel,
|
||||
wizard: wizardTestCase.minimumLevel,
|
||||
};
|
||||
const description = JSON.stringify(minimumLevels);
|
||||
combinedTestCases.push({
|
||||
minimumLevels: {
|
||||
healer: healerTestCase.minimumLevel,
|
||||
sorcerer: sorcererTestCase.minimumLevel,
|
||||
wizard: wizardTestCase.minimumLevel,
|
||||
},
|
||||
minimumLevels,
|
||||
expected,
|
||||
description,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +157,15 @@ function buildCombinedTestCases(): CombinedTestCase[] {
|
|||
|
||||
for (const spellCasterClass of ["healer", "sorcerer", "wizard"] as const) {
|
||||
for (const testCase of testCases[spellCasterClass].filter(isRelevantSingleTestCase)) {
|
||||
const minimumLevels = {
|
||||
...defaultData.minimumLevels,
|
||||
[spellCasterClass]: testCase.minimumLevel,
|
||||
};
|
||||
const description = JSON.stringify(minimumLevels);
|
||||
combinedTestCases.push({
|
||||
minimumLevels: {
|
||||
...defaultData.minimumLevels,
|
||||
[spellCasterClass]: testCase.minimumLevel,
|
||||
},
|
||||
minimumLevels,
|
||||
expected: testCase.expected,
|
||||
description,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +194,7 @@ describe("calculateSpellPrice", () => {
|
|||
};
|
||||
|
||||
it.each(buildCombinedTestCases())(
|
||||
`returns ${factor} × $expected if the minimum leves are $minimumLevels`,
|
||||
`returns ${factor} × $expected if the minimum leves are $description`,
|
||||
({ minimumLevels, expected }) => {
|
||||
// given
|
||||
const data: DS4SpellDataSourceData = {
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import en from "../../lang/en.json";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import de from "../../lang/de.json";
|
||||
import en from "../../lang/en.json";
|
||||
|
||||
describe("English and german localization files", () => {
|
||||
it("should have the same keys.", () => {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import evaluateCheck from "../../src/rolls/check-evaluation";
|
||||
|
||||
describe("evaluateCheck with no dice", () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["@league-of-foundry-developers/foundry-vtt-types", "jest"]
|
||||
"types": ["@league-of-foundry-developers/foundry-vtt-types"]
|
||||
},
|
||||
"include": ["../src", "./"]
|
||||
}
|
||||
|
|
11
vite.config.js
Normal file
11
vite.config.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
setupFiles: ["./spec/setup.ts"],
|
||||
},
|
||||
});
|
Loading…
Reference in a new issue