]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: move custom matcher types to setup-vitest.ts (#11252)
authorTycho <jh.leong@outlook.com>
Sat, 29 Jun 2024 14:26:30 +0000 (22:26 +0800)
committerGitHub <noreply@github.com>
Sat, 29 Jun 2024 14:26:30 +0000 (22:26 +0800)
packages/global.d.ts
scripts/setup-vitest.ts

index 1bae0b929fb4beacc79330a0660efc7cd08a1de3..79b551713845fed1d0c81921f6197eafdcbc522e 100644 (file)
@@ -19,15 +19,6 @@ declare var __FEATURE_PROD_DEVTOOLS__: boolean
 declare var __FEATURE_SUSPENSE__: boolean
 declare var __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: boolean
 
-// for tests
-declare namespace jest {
-  interface Matchers<R, T> {
-    toHaveBeenWarned(): R
-    toHaveBeenWarnedLast(): R
-    toHaveBeenWarnedTimes(n: number): R
-  }
-}
-
 declare module '*.vue' {}
 
 declare module 'file-saver' {
index 53e7f5fff569b5e995012430534c5cf036a6e077..08203572aff7c4e041dc85611253a13af0386584 100644 (file)
@@ -1,5 +1,16 @@
 import type { MockInstance } from 'vitest'
 
+declare module 'vitest' {
+  interface Assertion<T = any> extends CustomMatchers<T> {}
+  interface AsymmetricMatchersContaining extends CustomMatchers {}
+}
+
+interface CustomMatchers<R = unknown> {
+  toHaveBeenWarned(): R
+  toHaveBeenWarnedLast(): R
+  toHaveBeenWarnedTimes(n: number): R
+}
+
 vi.stubGlobal('MathMLElement', class MathMLElement {})
 
 expect.extend({