diff --git a/package.json b/package.json index 18f336b..b548099 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "jsdom": "^20.0.0", "prettier": "^2.5.1", "typescript": "^4.7.4", - "vitest": "^0.27.3", + "vitest": "^0.28.6", "vue-tsc": "^0.38.1" }, "engines": { diff --git a/tests/game/formulas.test.ts b/tests/game/formulas.test.ts index d9be004..eed9d42 100644 --- a/tests/game/formulas.test.ts +++ b/tests/game/formulas.test.ts @@ -11,8 +11,22 @@ import { ref } from "vue"; type FormulaFunctions = keyof GenericFormula & keyof typeof Formula & keyof typeof Decimal; +interface CustomMatchers { + compare_tolerance(expected: DecimalSource): R; +} + +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace Vi { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface Assertion extends CustomMatchers {} + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface AsymmetricMatchersContaining extends CustomMatchers {} + } +} + expect.extend({ - compare_tolerance(received, expected) { + compare_tolerance(received: DecimalSource, expected: DecimalSource) { const { isNot } = this; let pass = false; if (!Decimal.isFinite(expected)) { @@ -35,20 +49,6 @@ expect.extend({ } }); -interface CustomMatchers { - compare_tolerance(expected: DecimalSource): R; -} - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Vi { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Assertion extends CustomMatchers {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface AsymmetricMatchersContaining extends CustomMatchers {} - } -} - const testValues = ["-1e400", 0, 0.25] as const; const invertibleZeroParamFunctionNames = [ diff --git a/vite.config.ts b/vite.config.ts index 080d8e6..f3ce360 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -57,8 +57,5 @@ export default defineConfig({ ] } }) - ], - test: { - environment: "jsdom" - } + ] }); diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..3ab791b --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,9 @@ +import { mergeConfig } from 'vite' +import { defineConfig } from 'vitest/config' +import viteConfig from './vite.config' + +export default mergeConfig(viteConfig, defineConfig({ + test: { + environment: "jsdom" + } +}))