From dbd3c9d0af5872ad902a6f8f1428f8c7dc06267f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 10 Dec 2024 10:11:56 +0000 Subject: [PATCH] chore: couple changes --- packages/fuel-gauge/tsconfig.json | 2 +- packages/utils/global.d.ts | 13 ------------- packages/utils/src/test-utils.ts | 1 + .../{vitest.matcher.ts => vitest.matchers.ts} | 14 +++++++++++++- packages/utils/tsconfig.json | 2 +- packages/utils/vitest.setup.ts | 3 --- vitest.setup-files.ts | 3 +++ vitest.shared.config.mts | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 packages/utils/global.d.ts rename packages/utils/src/test-utils/{vitest.matcher.ts => vitest.matchers.ts} (65%) delete mode 100644 packages/utils/vitest.setup.ts create mode 100644 vitest.setup-files.ts diff --git a/packages/fuel-gauge/tsconfig.json b/packages/fuel-gauge/tsconfig.json index 968f826bbc9..1ff6687d7a9 100644 --- a/packages/fuel-gauge/tsconfig.json +++ b/packages/fuel-gauge/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "./dist", - "types": ["vitest/globals", "@fuel-ts/utils/global"] + "types": ["vitest/globals", "@fuel-ts/utils/test-utils"] }, "include": ["src", "test"] } diff --git a/packages/utils/global.d.ts b/packages/utils/global.d.ts deleted file mode 100644 index aae887687f7..00000000000 --- a/packages/utils/global.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { BN, BNInput } from '@fuel-ts/math'; - -interface Matchers { - toEqualBn: (expected: BNInput) => R; -} - -declare module 'vitest' { - interface Assertion extends Matchers {} - interface AsymmetricMatchersContaining extends Matchers {} - interface ExpectStatic { - toEqualBn(expected: BNInput): BN; - } -} diff --git a/packages/utils/src/test-utils.ts b/packages/utils/src/test-utils.ts index bfad80a17ed..266fa8b5b55 100644 --- a/packages/utils/src/test-utils.ts +++ b/packages/utils/src/test-utils.ts @@ -2,3 +2,4 @@ export * from './test-utils/getForcProject'; export * from './test-utils/expectToBeInRange'; export * from './test-utils/constants'; export * from './test-utils/wait-until-unreachable'; +export * from './test-utils/vitest.matchers'; diff --git a/packages/utils/src/test-utils/vitest.matcher.ts b/packages/utils/src/test-utils/vitest.matchers.ts similarity index 65% rename from packages/utils/src/test-utils/vitest.matcher.ts rename to packages/utils/src/test-utils/vitest.matchers.ts index 8daeb3fc957..275647a9769 100644 --- a/packages/utils/src/test-utils/vitest.matcher.ts +++ b/packages/utils/src/test-utils/vitest.matchers.ts @@ -1,5 +1,17 @@ import { bn } from '@fuel-ts/math'; -import type { BNInput } from '@fuel-ts/math'; +import type { BN, BNInput } from '@fuel-ts/math'; + +interface Matchers { + toEqualBn: (expected: BNInput) => R; +} + +declare module 'vitest' { + interface Assertion extends Matchers {} + interface AsymmetricMatchersContaining extends Matchers {} + interface ExpectStatic { + toEqualBn(expected: BNInput): BN; + } +} export const setupTestMatchers = () => { expect.extend({ diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index ac17ae8db77..b22c89a4b35 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "./dist" }, - "include": ["src", "test", "global.d.ts"] + "include": ["src", "test"] } diff --git a/packages/utils/vitest.setup.ts b/packages/utils/vitest.setup.ts deleted file mode 100644 index cc5509d5748..00000000000 --- a/packages/utils/vitest.setup.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { setupTestMatchers } from './src/test-utils/vitest.matcher'; - -setupTestMatchers(); diff --git a/vitest.setup-files.ts b/vitest.setup-files.ts new file mode 100644 index 00000000000..8cd866cc303 --- /dev/null +++ b/vitest.setup-files.ts @@ -0,0 +1,3 @@ +import { setupTestMatchers } from '@fuel-ts/utils/test-utils'; + +setupTestMatchers(); diff --git a/vitest.shared.config.mts b/vitest.shared.config.mts index d671785401c..799cd7bc2e5 100644 --- a/vitest.shared.config.mts +++ b/vitest.shared.config.mts @@ -17,7 +17,7 @@ export default defineConfig({ esbuild: { target: "es2022" }, test: { globalSetup: ["vitest.global-setup.ts"], - setupFiles: ["./packages/utils/vitest.setup.ts"], + setupFiles: ["./vitest.setup-files.ts"], coverage: { enabled: true, provider: "istanbul",