]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip(vitest-migration): reactivity tests passing
authorEvan You <yyx990803@gmail.com>
Thu, 26 Jan 2023 07:25:55 +0000 (15:25 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 26 Jan 2023 07:25:55 +0000 (15:25 +0800)
83 files changed:
package.json
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/__tests__/transform.spec.ts
packages/compiler-core/__tests__/transforms/transformElement.spec.ts
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts
packages/compiler-core/__tests__/transforms/transformSlotOutlet.spec.ts
packages/compiler-core/__tests__/transforms/vBind.spec.ts
packages/compiler-core/__tests__/transforms/vFor.spec.ts
packages/compiler-core/__tests__/transforms/vIf.spec.ts
packages/compiler-core/__tests__/transforms/vModel.spec.ts
packages/compiler-core/__tests__/transforms/vOn.spec.ts
packages/compiler-core/__tests__/transforms/vSlot.spec.ts
packages/compiler-dom/__tests__/transforms/Transition.spec.ts
packages/compiler-dom/__tests__/transforms/vHtml.spec.ts
packages/compiler-dom/__tests__/transforms/vModel.spec.ts
packages/compiler-dom/__tests__/transforms/vShow.spec.ts
packages/compiler-dom/__tests__/transforms/vText.spec.ts
packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap
packages/reactivity/__tests__/collections/Map.spec.ts
packages/reactivity/__tests__/collections/Set.spec.ts
packages/reactivity/__tests__/collections/WeakMap.spec.ts
packages/reactivity/__tests__/collections/WeakSet.spec.ts
packages/reactivity/__tests__/computed.spec.ts
packages/reactivity/__tests__/deferredComputed.spec.ts
packages/reactivity/__tests__/effect.spec.ts
packages/reactivity/__tests__/effectScope.spec.ts
packages/reactivity/__tests__/reactiveArray.spec.ts
packages/reactivity/__tests__/ref.spec.ts
packages/reactivity/__tests__/shallowReactive.spec.ts
packages/runtime-core/__tests__/apiAsyncComponent.spec.ts
packages/runtime-core/__tests__/apiCreateApp.spec.ts
packages/runtime-core/__tests__/apiLifecycle.spec.ts
packages/runtime-core/__tests__/apiOptions.spec.ts
packages/runtime-core/__tests__/apiSetupContext.spec.ts
packages/runtime-core/__tests__/apiSetupHelpers.spec.ts
packages/runtime-core/__tests__/apiWatch.spec.ts
packages/runtime-core/__tests__/componentEmits.spec.ts
packages/runtime-core/__tests__/componentProps.spec.ts
packages/runtime-core/__tests__/componentPublicInstance.spec.ts
packages/runtime-core/__tests__/componentSlots.spec.ts
packages/runtime-core/__tests__/components/BaseTransition.spec.ts
packages/runtime-core/__tests__/components/KeepAlive.spec.ts
packages/runtime-core/__tests__/components/Suspense.spec.ts
packages/runtime-core/__tests__/components/Teleport.spec.ts
packages/runtime-core/__tests__/directives.spec.ts
packages/runtime-core/__tests__/errorHandling.spec.ts
packages/runtime-core/__tests__/hmr.spec.ts
packages/runtime-core/__tests__/hydration.spec.ts
packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts
packages/runtime-core/__tests__/rendererComponent.spec.ts
packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts
packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
packages/runtime-core/__tests__/scheduler.spec.ts
packages/runtime-core/__tests__/vnode.spec.ts
packages/runtime-core/__tests__/vnodeHooks.spec.ts
packages/runtime-core/src/apiLifecycle.ts
packages/runtime-core/src/component.ts
packages/runtime-core/src/enums.ts [new file with mode: 0644]
packages/runtime-core/src/errorHandling.ts
packages/runtime-dom/__tests__/createApp.spec.ts
packages/runtime-dom/__tests__/customElement.spec.ts
packages/runtime-dom/__tests__/customizedBuiltIn.spec.ts
packages/runtime-dom/__tests__/directives/vModel.spec.ts
packages/runtime-dom/__tests__/directives/vOn.spec.ts
packages/runtime-dom/__tests__/patchEvents.spec.ts
packages/runtime-dom/__tests__/patchProps.spec.ts
packages/runtime-dom/__tests__/patchStyle.spec.ts
packages/server-renderer/__tests__/render.spec.ts
packages/server-renderer/__tests__/ssrComputed.spec.ts
packages/server-renderer/__tests__/ssrSuspense.spec.ts
packages/vue-compat/__tests__/compiler.spec.ts
packages/vue-compat/__tests__/global.spec.ts
packages/vue-compat/__tests__/globalConfig.spec.ts
packages/vue-compat/__tests__/instance.spec.ts
packages/vue-compat/__tests__/misc.spec.ts
packages/vue-compat/__tests__/options.spec.ts
packages/vue/__tests__/Transition.spec.ts
packages/vue/__tests__/TransitionGroup.spec.ts
packages/vue/__tests__/customElementCasing.spec.ts
packages/vue/__tests__/index.spec.ts
pnpm-lock.yaml
scripts/setupVitest.ts [new file with mode: 0644]
vitest.config.ts [new file with mode: 0644]

index 9f1440efa780fb20d1e9ac23f580634076260d59..faf4dcd92f92d38dd655cae57a0fcb3d09e49bbe 100644 (file)
     "tslib": "^2.4.0",
     "typescript": "^4.8.0",
     "vite": "^4.0.4",
+    "vitest": "^0.28.2",
     "vue": "workspace:*"
   }
 }
index c4e1a3f2fcedd181d78c3b8448c68c31ea8fef1a..f86b916081079e98e6d7557de18870c2d368b715 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { ParserOptions } from '../src/options'
 import { baseParse, TextModes } from '../src/parse'
 import { ErrorCodes } from '../src/errors'
@@ -31,7 +32,7 @@ describe('compiler: parse', () => {
     })
 
     test('simple text with invalid end tag', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const ast = baseParse('some text</div>', {
         onError
       })
@@ -1844,7 +1845,7 @@ describe('compiler: parse', () => {
       baseParse(`<div>\n<span>\n</div>\n</span>`)
     }).toThrow('Element is missing end tag.')
 
-    const spy = jest.fn()
+    const spy = vi.fn()
     const ast = baseParse(`<div>\n<span>\n</div>\n</span>`, {
       onError: spy
     })
@@ -3034,7 +3035,7 @@ foo
               c => `\\x0${c.codePointAt(0)!.toString(16)};`
             ),
             () => {
-              const spy = jest.fn()
+              const spy = vi.fn()
               const ast = baseParse(code, {
                 getNamespace: (tag, parent) => {
                   const ns = parent ? parent.ns : Namespaces.HTML
index 89f0ecda56e52e72b82e96eecfa4a1e5d6aaa804..915ae7a60cd262e94cb938a85891b8145a939c7c 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { baseParse } from '../src/parse'
 import { transform, NodeTransform } from '../src/transform'
 import {
@@ -88,7 +89,7 @@ describe('compiler: transform', () => {
         )
       }
     }
-    const spy = jest.fn(plugin)
+    const spy = vi.fn(plugin)
     transform(ast, {
       nodeTransforms: [spy]
     })
@@ -113,7 +114,7 @@ describe('compiler: transform', () => {
         context.removeNode()
       }
     }
-    const spy = jest.fn(plugin)
+    const spy = vi.fn(plugin)
     transform(ast, {
       nodeTransforms: [spy]
     })
@@ -141,7 +142,7 @@ describe('compiler: transform', () => {
         context.removeNode(context.parent!.children[0])
       }
     }
-    const spy = jest.fn(plugin)
+    const spy = vi.fn(plugin)
     transform(ast, {
       nodeTransforms: [spy]
     })
@@ -168,7 +169,7 @@ describe('compiler: transform', () => {
         context.removeNode(context.parent!.children[1])
       }
     }
-    const spy = jest.fn(plugin)
+    const spy = vi.fn(plugin)
     transform(ast, {
       nodeTransforms: [spy]
     })
@@ -209,7 +210,7 @@ describe('compiler: transform', () => {
         createCompilerError(ErrorCodes.X_INVALID_END_TAG, node.loc)
       )
     }
-    const spy = jest.fn()
+    const spy = vi.fn()
     transform(ast, {
       nodeTransforms: [plugin],
       onError: spy
index 06fd2e12b1907c34e388ad69f7353a452f4a8004..1c90e33fcb77faa5a5934b5b212d431dd2a1d29d 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   CompilerOptions,
   baseParse as parse,
@@ -531,7 +532,7 @@ describe('compiler: element transform', () => {
   })
 
   test('error on v-bind with no argument', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     parseWithElementTransform(`<div v-bind/>`, { onError })
     expect(onError.mock.calls[0]).toMatchObject([
       {
index 4db7aa619037e3cf3a716e76d3d4194be7740842..b9593c4a4bef8ab2b36c43903c37242cafa27a94 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -395,7 +396,7 @@ describe('compiler: expression transform', () => {
   })
 
   test('should handle parse error', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     parseWithExpressionTransform(`{{ a( }}`, { onError })
     expect(onError.mock.calls[0][0].message).toMatch(
       `Error parsing JavaScript expression: Unexpected token`
index fd5bd09c0f1982a506edab74b1065c4e9598395c..e3863f1edf9b1503c168210cd09585e669cbd572 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   CompilerOptions,
   baseParse as parse,
@@ -369,7 +370,7 @@ describe('compiler: transform <slot> outlets', () => {
   })
 
   test(`error on unexpected custom directive on <slot>`, () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     const source = `<slot v-foo />`
     parseWithSlots(source, { onError })
     const index = source.indexOf('v-foo')
index 27e0ae10c8124410a24b9e824645e7232e77d083..ea5bdcf3d52147f827bc62a5c5308fcb62bbc1f2 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -99,7 +100,7 @@ describe('compiler: transform v-bind', () => {
   })
 
   test('should error if no expression', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     const node = parseWithVBind(`<div v-bind:arg />`, { onError })
     const props = (node.codegenNode as VNodeCall).props as ObjectExpression
     expect(onError.mock.calls[0][0]).toMatchObject({
index c22b364aa615dc7dc47b441f5627e91d54f48320..b07272ef72b71d82401b86d0c1dd6d5c3932aff7 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { baseParse as parse } from '../../src/parse'
 import { transform } from '../../src/transform'
 import { transformIf } from '../../src/transforms/vIf'
@@ -206,7 +207,7 @@ describe('compiler: v-for', () => {
 
   describe('errors', () => {
     test('missing expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform('<span v-for />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -218,7 +219,7 @@ describe('compiler: v-for', () => {
     })
 
     test('empty expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform('<span v-for="" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -230,7 +231,7 @@ describe('compiler: v-for', () => {
     })
 
     test('invalid expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform('<span v-for="items" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -242,7 +243,7 @@ describe('compiler: v-for', () => {
     })
 
     test('missing source', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform('<span v-for="item in" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -254,7 +255,7 @@ describe('compiler: v-for', () => {
     })
 
     test('missing value', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform('<span v-for="in items" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -266,7 +267,7 @@ describe('compiler: v-for', () => {
     })
 
     test('<template v-for> key placement', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithForTransform(
         `
       <template v-for="item in items">
index 225f6d6082cd951220457dd540c8c07c67d2871d..1b42b20c7b83b46faa11acc1e75c2c09afd6e99c 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { baseParse as parse } from '../../src/parse'
 import { transform } from '../../src/transform'
 import { transformIf } from '../../src/transforms/vIf'
@@ -213,7 +214,7 @@ describe('compiler: v-if', () => {
 
   describe('errors', () => {
     test('error on v-else missing adjacent v-if', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
 
       const { node: node1 } = parseWithIfTransform(`<div v-else/>`, { onError })
       expect(onError.mock.calls[0]).toMatchObject([
@@ -249,7 +250,7 @@ describe('compiler: v-if', () => {
     })
 
     test('error on v-else-if missing adjacent v-if or v-else-if', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
 
       const { node: node1 } = parseWithIfTransform(`<div v-else-if="foo"/>`, {
         onError
@@ -302,7 +303,7 @@ describe('compiler: v-if', () => {
     })
 
     test('error on user key', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       // dynamic
       parseWithIfTransform(
         `<div v-if="ok" :key="a + 1" /><div v-else :key="a + 1" />`,
index 808fb94215ef832116029cbbddb8eb46afeb6ed0..df8f6e024168132ba6d543acb86d0dea7de70b09 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -506,7 +507,7 @@ describe('compiler: transform v-model', () => {
 
   describe('errors', () => {
     test('missing expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<span v-model />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -518,7 +519,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('empty expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<span v-model="" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -530,7 +531,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('mal-formed expression', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<span v-model="a + b" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -542,14 +543,14 @@ describe('compiler: transform v-model', () => {
     })
 
     test('allow unicode', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<span v-model="变.量" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(0)
     })
 
     test('used on scope variable', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<span v-for="i in list" v-model="i" />', {
         onError,
         prefixIdentifiers: true
@@ -564,7 +565,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('used on props', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       parseWithVModel('<div v-model="p" />', {
         onError,
         bindingMetadata: {
index 4ed9ea23a8285988f571f3af87dea6adafde890b..721428a665eaf3e97255244e0d980ce158c04aea 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   CompilerOptions,
@@ -398,7 +399,7 @@ describe('compiler: transform v-on', () => {
   })
 
   test('should error if no expression AND no modifier', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     parseWithVOn(`<div v-on:click />`, { onError })
     expect(onError.mock.calls[0][0]).toMatchObject({
       code: ErrorCodes.X_V_ON_NO_EXPRESSION,
@@ -416,7 +417,7 @@ describe('compiler: transform v-on', () => {
   })
 
   test('should NOT error if no expression but has modifier', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     parseWithVOn(`<div v-on:click.prevent />`, { onError })
     expect(onError).not.toHaveBeenCalled()
   })
index c166f8d160a25e0dc0cc448f08d60a2a7969e48d..d111aab6b4fff90e36af333aa12a4896e0c4a237 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   CompilerOptions,
   baseParse as parse,
@@ -843,7 +844,7 @@ describe('compiler: transform component slots', () => {
 
   describe('errors', () => {
     test('error on extraneous children w/ named default slot', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const source = `<Comp><template #default>foo</template>bar</Comp>`
       parseWithSlots(source, { onError })
       const index = source.indexOf('bar')
@@ -866,7 +867,7 @@ describe('compiler: transform component slots', () => {
     })
 
     test('error on duplicated slot names', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const source = `<Comp><template #foo></template><template #foo></template></Comp>`
       parseWithSlots(source, { onError })
       const index = source.lastIndexOf('#foo')
@@ -889,7 +890,7 @@ describe('compiler: transform component slots', () => {
     })
 
     test('error on invalid mixed slot usage', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const source = `<Comp v-slot="foo"><template #foo></template></Comp>`
       parseWithSlots(source, { onError })
       const index = source.lastIndexOf('#foo')
@@ -912,7 +913,7 @@ describe('compiler: transform component slots', () => {
     })
 
     test('error on v-slot usage on plain elements', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const source = `<div v-slot/>`
       parseWithSlots(source, { onError })
       const index = source.indexOf('v-slot')
index 1ae71360778ec8d3ee5b24005f9dfe5c15719439..1711c1d2659d65eb9389bc9108098204b8e766ce 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { compile } from '../../src'
 
 describe('Transition multi children warnings', () => {
@@ -6,7 +7,7 @@ describe('Transition multi children warnings', () => {
     shouldWarn: boolean,
     message = `<Transition> expects exactly one child element or component.`
   ) {
-    const spy = jest.fn()
+    const spy = vi.fn()
     compile(template.trim(), {
       hoistStatic: true,
       transformHoist: null,
index 8c441cef0e47275922424a2da6089973f23753f8..29478676857655f4c60ee4a2aac1af46688695e8 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -40,7 +41,7 @@ describe('compiler: v-html transform', () => {
   })
 
   it('should raise error and ignore children when v-html is present', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     const ast = transformWithVHtml(`<div v-html="test">hello</div>`, {
       onError
     })
@@ -59,7 +60,7 @@ describe('compiler: v-html transform', () => {
   })
 
   it('should raise error if has no expression', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     transformWithVHtml(`<div v-html></div>`, {
       onError
     })
index 3da0b30085fedaa6e71026dbeba654fb98b9596b..75750a8ceb56acc3c62f725402def93e2761d10a 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -92,7 +93,7 @@ describe('compiler: transform v-model', () => {
 
   describe('errors', () => {
     test('plain elements with argument', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       transformWithModel('<input v-model:value="model" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -104,7 +105,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('invalid element', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       transformWithModel('<span v-model="model" />', { onError })
 
       expect(onError).toHaveBeenCalledTimes(1)
@@ -116,7 +117,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('should allow usage on custom element', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       const root = transformWithModel('<my-input v-model="model" />', {
         onError,
         isCustomElement: tag => tag.startsWith('my-')
@@ -127,7 +128,7 @@ describe('compiler: transform v-model', () => {
     })
 
     test('should raise error if used file input element', () => {
-      const onError = jest.fn()
+      const onError = vi.fn()
       transformWithModel(`<input type="file" v-model="test"/>`, {
         onError
       })
index 3c70741cb829e7161f52e896a59af982ab07935a..9fb53974deb1ad31b34a270f321c9ccd05c0ef6b 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -28,7 +29,7 @@ describe('compiler: v-show transform', () => {
   })
 
   test('should raise error if has no expression', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     transformWithShow(`<div v-show/>`, { onError })
 
     expect(onError).toHaveBeenCalledTimes(1)
index 75dbda31fd10d29944a6208ecc22672265f6c364..5c500b31f1c5d787e892aca238700946da1fdf28 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   baseParse as parse,
   transform,
@@ -42,7 +43,7 @@ describe('compiler: v-text transform', () => {
   })
 
   it('should raise error and ignore children when v-text is present', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     const ast = transformWithVText(`<div v-text="test">hello</div>`, {
       onError
     })
@@ -63,7 +64,7 @@ describe('compiler: v-text transform', () => {
   })
 
   it('should raise error if has no expression', () => {
-    const onError = jest.fn()
+    const onError = vi.fn()
     transformWithVText(`<div v-text></div>`, {
       onError
     })
index 26490ac9d9d9a5d92c86c7b553286b67e0541b46..edccb5f11f66929b24ff0dd6c8805fde22796cc5 100644 (file)
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Vitest Snapshot v1
 
 exports[`$ unwrapping 1`] = `
 "
index 27ee5b103fb8028cb05f535f8a963342da314475..aa4874014f679f430be5d9d1d07d8f700d014aec 100644 (file)
@@ -1,8 +1,9 @@
+import { vi } from 'vitest'
 import { reactive, effect, toRaw, isReactive } from '../../src'
 
 describe('reactivity/collections', () => {
   function coverCollectionFn(collection: Map<any, any>, fnName: string) {
-    const spy = jest.fn()
+    const spy = vi.fn()
     let proxy = reactive(collection)
     ;(collection as any)[fnName] = spy
     return [proxy as any, spy]
@@ -216,7 +217,7 @@ describe('reactivity/collections', () => {
     it('should not observe non value changing mutations', () => {
       let dummy
       const map = reactive(new Map())
-      const mapSpy = jest.fn(() => (dummy = map.get('key')))
+      const mapSpy = vi.fn(() => (dummy = map.get('key')))
       effect(mapSpy)
 
       expect(dummy).toBe(undefined)
@@ -350,7 +351,7 @@ describe('reactivity/collections', () => {
 
     it('should not be trigger when the value and the old value both are NaN', () => {
       const map = reactive(new Map([['foo', NaN]]))
-      const mapSpy = jest.fn(() => map.get('foo'))
+      const mapSpy = vi.fn(() => map.get('foo'))
       effect(mapSpy)
       map.set('foo', NaN)
       expect(mapSpy).toHaveBeenCalledTimes(1)
@@ -418,7 +419,7 @@ describe('reactivity/collections', () => {
     // #877
     it('should not trigger key iteration when setting existing keys', () => {
       const map = reactive(new Map())
-      const spy = jest.fn()
+      const spy = vi.fn()
 
       effect(() => {
         const keys = []
index 5bd5f24640b8004331aeba01e642cc6df452df3e..4fd29876f4cca509eb38cc17a4f24fde61db06ca 100644 (file)
@@ -1,8 +1,9 @@
+import { vi } from 'vitest'
 import { reactive, effect, isReactive, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
   function coverCollectionFn(collection: Set<any>, fnName: string) {
-    const spy = jest.fn()
+    const spy = vi.fn()
     let proxy = reactive(collection)
     ;(collection as any)[fnName] = spy
     return [proxy as any, spy]
@@ -182,7 +183,7 @@ describe('reactivity/collections', () => {
     it('should not observe non value changing mutations', () => {
       let dummy
       const set = reactive(new Set())
-      const setSpy = jest.fn(() => (dummy = set.has('value')))
+      const setSpy = vi.fn(() => (dummy = set.has('value')))
       effect(setSpy)
 
       expect(dummy).toBe(false)
@@ -283,7 +284,7 @@ describe('reactivity/collections', () => {
       let dummy
       const key = {}
       const set = reactive(new Set())
-      const setSpy = jest.fn(() => (dummy = set.has(key)))
+      const setSpy = vi.fn(() => (dummy = set.has(key)))
       effect(setSpy)
 
       expect(dummy).toBe(false)
index 31613a06572127f26ca0d1cc27e0924a9fefbf97..a8f722458f7eb9b287887056879343fbb5966c34 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { reactive, effect, toRaw, isReactive } from '../../src'
 
 describe('reactivity/collections', () => {
@@ -57,7 +58,7 @@ describe('reactivity/collections', () => {
       let dummy
       const key = {}
       const map = reactive(new WeakMap())
-      const mapSpy = jest.fn(() => (dummy = map.get(key)))
+      const mapSpy = vi.fn(() => (dummy = map.get(key)))
       effect(mapSpy)
 
       expect(dummy).toBe(undefined)
@@ -128,7 +129,7 @@ describe('reactivity/collections', () => {
       const map = new WeakMap()
       const key = {}
       map.set(key, NaN)
-      const mapSpy = jest.fn(() => map.get(key))
+      const mapSpy = vi.fn(() => map.get(key))
       effect(mapSpy)
       map.set(key, NaN)
       expect(mapSpy).toHaveBeenCalledTimes(1)
index 01512b0eeefda7784d8d31bf40f340b4f98433fc..646f1a235f32d352c8dc4ad009e528687654a600 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { reactive, isReactive, effect, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
@@ -50,7 +51,7 @@ describe('reactivity/collections', () => {
       let dummy
       const value = {}
       const set = reactive(new WeakSet())
-      const setSpy = jest.fn(() => (dummy = set.has(value)))
+      const setSpy = vi.fn(() => (dummy = set.has(value)))
       effect(setSpy)
 
       expect(dummy).toBe(false)
index 3e4dead83719399c650143a61f3ad5f3660335dd..511579443557c1faa83da8c4cbf6756b80505142 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   computed,
   reactive,
@@ -23,7 +24,7 @@ describe('reactivity/computed', () => {
 
   it('should compute lazily', () => {
     const value = reactive<{ foo?: number }>({})
-    const getter = jest.fn(() => value.foo)
+    const getter = vi.fn(() => value.foo)
     const cValue = computed(getter)
 
     // lazy
@@ -74,8 +75,8 @@ describe('reactivity/computed', () => {
 
   it('should trigger effect when chained', () => {
     const value = reactive({ foo: 0 })
-    const getter1 = jest.fn(() => value.foo)
-    const getter2 = jest.fn(() => {
+    const getter1 = vi.fn(() => value.foo)
+    const getter2 = vi.fn(() => {
       return c1.value + 1
     })
     const c1 = computed(getter1)
@@ -97,8 +98,8 @@ describe('reactivity/computed', () => {
 
   it('should trigger effect when chained (mixed invocations)', () => {
     const value = reactive({ foo: 0 })
-    const getter1 = jest.fn(() => value.foo)
-    const getter2 = jest.fn(() => {
+    const getter1 = vi.fn(() => value.foo)
+    const getter2 = vi.fn(() => {
       return c1.value + 1
     })
     const c1 = computed(getter1)
@@ -223,7 +224,7 @@ describe('reactivity/computed', () => {
 
   it('debug: onTrack', () => {
     let events: DebuggerEvent[] = []
-    const onTrack = jest.fn((e: DebuggerEvent) => {
+    const onTrack = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive({ foo: 1, bar: 2 })
@@ -256,7 +257,7 @@ describe('reactivity/computed', () => {
 
   it('debug: onTrigger', () => {
     let events: DebuggerEvent[] = []
-    const onTrigger = jest.fn((e: DebuggerEvent) => {
+    const onTrigger = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive({ foo: 1 })
index 3940280176aa2eefc5e8000980a4be65da161be5..51ee5a18be65bd5af6f6c4494cf1398c757d0ced 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { computed, deferredComputed, effect, ref } from '../src'
 
 describe('deferred computed', () => {
@@ -6,7 +7,7 @@ describe('deferred computed', () => {
   test('should only trigger once on multiple mutations', async () => {
     const src = ref(0)
     const c = deferredComputed(() => src.value)
-    const spy = jest.fn()
+    const spy = vi.fn()
     effect(() => {
       spy(c.value)
     })
@@ -25,7 +26,7 @@ describe('deferred computed', () => {
   test('should not trigger if value did not change', async () => {
     const src = ref(0)
     const c = deferredComputed(() => src.value % 2)
-    const spy = jest.fn()
+    const spy = vi.fn()
     effect(() => {
       spy(c.value)
     })
@@ -46,9 +47,9 @@ describe('deferred computed', () => {
   })
 
   test('chained computed trigger', async () => {
-    const effectSpy = jest.fn()
-    const c1Spy = jest.fn()
-    const c2Spy = jest.fn()
+    const effectSpy = vi.fn()
+    const c1Spy = vi.fn()
+    const c2Spy = vi.fn()
 
     const src = ref(0)
     const c1 = deferredComputed(() => {
@@ -76,9 +77,9 @@ describe('deferred computed', () => {
   })
 
   test('chained computed avoid re-compute', async () => {
-    const effectSpy = jest.fn()
-    const c1Spy = jest.fn()
-    const c2Spy = jest.fn()
+    const effectSpy = vi.fn()
+    const c1Spy = vi.fn()
+    const c2Spy = vi.fn()
 
     const src = ref(0)
     const c1 = deferredComputed(() => {
@@ -108,9 +109,9 @@ describe('deferred computed', () => {
   })
 
   test('chained computed value invalidation', async () => {
-    const effectSpy = jest.fn()
-    const c1Spy = jest.fn()
-    const c2Spy = jest.fn()
+    const effectSpy = vi.fn()
+    const c1Spy = vi.fn()
+    const c2Spy = vi.fn()
 
     const src = ref(0)
     const c1 = deferredComputed(() => {
@@ -140,9 +141,9 @@ describe('deferred computed', () => {
   })
 
   test('sync access of invalidated chained computed should not prevent final effect from running', async () => {
-    const effectSpy = jest.fn()
-    const c1Spy = jest.fn()
-    const c2Spy = jest.fn()
+    const effectSpy = vi.fn()
+    const c1Spy = vi.fn()
+    const c2Spy = vi.fn()
 
     const src = ref(0)
     const c1 = deferredComputed(() => {
@@ -167,7 +168,7 @@ describe('deferred computed', () => {
   })
 
   test('should not compute if deactivated before scheduler is called', async () => {
-    const c1Spy = jest.fn()
+    const c1Spy = vi.fn()
     const src = ref(0)
     const c1 = deferredComputed(() => {
       c1Spy()
index ed23b18446a87f8f73aa9e2e1864eb536253dc15..035093207822e492ecb7c89bb669b2ca792cfbec 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ref,
   reactive,
@@ -16,7 +17,7 @@ import { ITERATE_KEY } from '../src/effect'
 
 describe('reactivity/effect', () => {
   it('should run the passed function once (wrapped by a effect)', () => {
-    const fnSpy = jest.fn(() => {})
+    const fnSpy = vi.fn(() => {})
     effect(fnSpy)
     expect(fnSpy).toHaveBeenCalledTimes(1)
   })
@@ -290,8 +291,8 @@ describe('reactivity/effect', () => {
     let hasDummy, getDummy
     const obj = reactive({ prop: 'value' })
 
-    const getSpy = jest.fn(() => (getDummy = obj.prop))
-    const hasSpy = jest.fn(() => (hasDummy = 'prop' in obj))
+    const getSpy = vi.fn(() => (getDummy = obj.prop))
+    const hasSpy = vi.fn(() => (hasDummy = 'prop' in obj))
     effect(getSpy)
     effect(hasSpy)
 
@@ -349,7 +350,7 @@ describe('reactivity/effect', () => {
   it('should avoid implicit infinite recursive loops with itself', () => {
     const counter = reactive({ num: 0 })
 
-    const counterSpy = jest.fn(() => counter.num++)
+    const counterSpy = vi.fn(() => counter.num++)
     effect(counterSpy)
     expect(counter.num).toBe(1)
     expect(counterSpy).toHaveBeenCalledTimes(1)
@@ -361,8 +362,8 @@ describe('reactivity/effect', () => {
   it('should avoid infinite recursive loops when use Array.prototype.push/unshift/pop/shift', () => {
     ;(['push', 'unshift'] as const).forEach(key => {
       const arr = reactive<number[]>([])
-      const counterSpy1 = jest.fn(() => (arr[key] as any)(1))
-      const counterSpy2 = jest.fn(() => (arr[key] as any)(2))
+      const counterSpy1 = vi.fn(() => (arr[key] as any)(1))
+      const counterSpy2 = vi.fn(() => (arr[key] as any)(2))
       effect(counterSpy1)
       effect(counterSpy2)
       expect(arr.length).toBe(2)
@@ -371,8 +372,8 @@ describe('reactivity/effect', () => {
     })
     ;(['pop', 'shift'] as const).forEach(key => {
       const arr = reactive<number[]>([1, 2, 3, 4])
-      const counterSpy1 = jest.fn(() => (arr[key] as any)())
-      const counterSpy2 = jest.fn(() => (arr[key] as any)())
+      const counterSpy1 = vi.fn(() => (arr[key] as any)())
+      const counterSpy2 = vi.fn(() => (arr[key] as any)())
       effect(counterSpy1)
       effect(counterSpy2)
       expect(arr.length).toBe(2)
@@ -383,7 +384,7 @@ describe('reactivity/effect', () => {
 
   it('should allow explicitly recursive raw function loops', () => {
     const counter = reactive({ num: 0 })
-    const numSpy = jest.fn(() => {
+    const numSpy = vi.fn(() => {
       counter.num++
       if (counter.num < 10) {
         numSpy()
@@ -397,8 +398,8 @@ describe('reactivity/effect', () => {
   it('should avoid infinite loops with other effects', () => {
     const nums = reactive({ num1: 0, num2: 1 })
 
-    const spy1 = jest.fn(() => (nums.num1 = nums.num2))
-    const spy2 = jest.fn(() => (nums.num2 = nums.num1))
+    const spy1 = vi.fn(() => (nums.num1 = nums.num2))
+    const spy2 = vi.fn(() => (nums.num2 = nums.num1))
     effect(spy1)
     effect(spy2)
     expect(nums.num1).toBe(1)
@@ -433,7 +434,7 @@ describe('reactivity/effect', () => {
     let dummy
     const obj = reactive({ prop: 'value', run: false })
 
-    const conditionalSpy = jest.fn(() => {
+    const conditionalSpy = vi.fn(() => {
       dummy = obj.run ? obj.prop : 'other'
     })
     effect(conditionalSpy)
@@ -473,7 +474,7 @@ describe('reactivity/effect', () => {
     let dummy
     const obj = reactive({ prop: 'value', run: true })
 
-    const conditionalSpy = jest.fn(() => {
+    const conditionalSpy = vi.fn(() => {
       dummy = obj.run ? obj.prop : 'other'
     })
     effect(conditionalSpy)
@@ -509,7 +510,7 @@ describe('reactivity/effect', () => {
     const input = reactive({ a: 1, b: 2, c: 0 })
     const output = reactive({ fx1: 0, fx2: 0 })
 
-    const fx1Spy = jest.fn(() => {
+    const fx1Spy = vi.fn(() => {
       let result = 0
       if (input.c < 2) result += input.a
       if (input.c > 1) result += input.b
@@ -518,7 +519,7 @@ describe('reactivity/effect', () => {
 
     const fx1 = effect(fx1Spy)
 
-    const fx2Spy = jest.fn(() => {
+    const fx2Spy = vi.fn(() => {
       let result = 0
       if (input.c > 1) result += input.a
       if (input.c < 3) result += input.b
@@ -588,7 +589,7 @@ describe('reactivity/effect', () => {
   it('should not run multiple times for a single mutation', () => {
     let dummy
     const obj = reactive<Record<string, number>>({})
-    const fnSpy = jest.fn(() => {
+    const fnSpy = vi.fn(() => {
       for (const key in obj) {
         dummy = obj[key]
       }
@@ -606,9 +607,9 @@ describe('reactivity/effect', () => {
     const nums = reactive({ num1: 0, num2: 1, num3: 2 })
     const dummy: any = {}
 
-    const childSpy = jest.fn(() => (dummy.num1 = nums.num1))
+    const childSpy = vi.fn(() => (dummy.num1 = nums.num1))
     const childeffect = effect(childSpy)
-    const parentSpy = jest.fn(() => {
+    const parentSpy = vi.fn(() => {
       dummy.num2 = nums.num2
       childeffect()
       dummy.num3 = nums.num3
@@ -680,7 +681,7 @@ describe('reactivity/effect', () => {
   it('scheduler', () => {
     let dummy
     let run: any
-    const scheduler = jest.fn(() => {
+    const scheduler = vi.fn(() => {
       run = runner
     })
     const obj = reactive({ foo: 1 })
@@ -706,7 +707,7 @@ describe('reactivity/effect', () => {
   it('events: onTrack', () => {
     let events: DebuggerEvent[] = []
     let dummy
-    const onTrack = jest.fn((e: DebuggerEvent) => {
+    const onTrack = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive({ foo: 1, bar: 2 })
@@ -745,7 +746,7 @@ describe('reactivity/effect', () => {
   it('events: onTrigger', () => {
     let events: DebuggerEvent[] = []
     let dummy
-    const onTrigger = jest.fn((e: DebuggerEvent) => {
+    const onTrigger = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive<{ foo?: number }>({ foo: 1 })
@@ -818,7 +819,7 @@ describe('reactivity/effect', () => {
   })
 
   it('events: onStop', () => {
-    const onStop = jest.fn()
+    const onStop = vi.fn()
     const runner = effect(() => {}, {
       onStop
     })
@@ -870,7 +871,7 @@ describe('reactivity/effect', () => {
     const obj = reactive({
       foo: NaN
     })
-    const fnSpy = jest.fn(() => obj.foo)
+    const fnSpy = vi.fn(() => obj.foo)
     effect(fnSpy)
     obj.foo = NaN
     expect(fnSpy).toHaveBeenCalledTimes(1)
@@ -903,7 +904,7 @@ describe('reactivity/effect', () => {
   it('should not be triggered when set with the same proxy', () => {
     const obj = reactive({ foo: 1 })
     const observed: any = reactive({ obj })
-    const fnSpy = jest.fn(() => observed.obj)
+    const fnSpy = vi.fn(() => observed.obj)
 
     effect(fnSpy)
 
@@ -913,7 +914,7 @@ describe('reactivity/effect', () => {
 
     const obj2 = reactive({ foo: 1 })
     const observed2: any = shallowReactive({ obj2 })
-    const fnSpy2 = jest.fn(() => observed2.obj2)
+    const fnSpy2 = vi.fn(() => observed2.obj2)
 
     effect(fnSpy2)
 
@@ -942,7 +943,7 @@ describe('reactivity/effect', () => {
     test('should work with readonly(reactive(Map))', () => {
       const m = reactive(new Map())
       const roM = readonly(m)
-      const fnSpy = jest.fn(() => roM.get(1))
+      const fnSpy = vi.fn(() => roM.get(1))
 
       effect(fnSpy)
       expect(fnSpy).toHaveBeenCalledTimes(1)
@@ -955,7 +956,7 @@ describe('reactivity/effect', () => {
       const m = reactive(new Map())
       m.set(key, 1)
       const roM = readonly(m)
-      const fnSpy = jest.fn(() => roM.get(key))
+      const fnSpy = vi.fn(() => roM.get(key))
 
       effect(fnSpy)
       expect(fnSpy).toHaveBeenCalledTimes(1)
@@ -968,7 +969,7 @@ describe('reactivity/effect', () => {
     test('should track hasOwnProperty', () => {
       const obj: any = reactive({})
       let has = false
-      const fnSpy = jest.fn()
+      const fnSpy = vi.fn()
 
       effect(() => {
         fnSpy()
index a670c1ebc07c55746b21fcc76a52e8c50e67ade9..a19aa0085fafaa15eccdd32560ed33ab3603fddb 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { nextTick, watch, watchEffect } from '@vue/runtime-core'
 import {
   reactive,
@@ -12,7 +13,7 @@ import {
 
 describe('reactivity/effect/scope', () => {
   it('should run', () => {
-    const fnSpy = jest.fn(() => {})
+    const fnSpy = vi.fn(() => {})
     new EffectScope().run(fnSpy)
     expect(fnSpy).toHaveBeenCalledTimes(1)
   })
@@ -202,7 +203,7 @@ describe('reactivity/effect/scope', () => {
   })
 
   it('should warn onScopeDispose() is called when there is no active effect scope', () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const scope = new EffectScope()
     scope.run(() => {
       onScopeDispose(spy)
@@ -231,9 +232,9 @@ describe('reactivity/effect/scope', () => {
   it('test with higher level APIs', async () => {
     const r = ref(1)
 
-    const computedSpy = jest.fn()
-    const watchSpy = jest.fn()
-    const watchEffectSpy = jest.fn()
+    const computedSpy = vi.fn()
+    const watchSpy = vi.fn()
+    const watchEffectSpy = vi.fn()
 
     let c: ComputedRef
     const scope = new EffectScope()
index ea7921c6a62c88fea406586bb98b83ea60456f4b..c76a0c94bec5ebee879cc52f809e309a710d085a 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { reactive, isReactive, toRaw } from '../src/reactive'
 import { ref, isRef } from '../src/ref'
 import { effect } from '../src/effect'
@@ -90,7 +91,7 @@ describe('reactivity/reactive/Array', () => {
 
   test('delete on Array should not trigger length dependency', () => {
     const arr = reactive([1, 2, 3])
-    const fn = jest.fn()
+    const fn = vi.fn()
     effect(() => {
       fn(arr.length)
     })
@@ -102,7 +103,7 @@ describe('reactivity/reactive/Array', () => {
   test('add existing index on Array should not trigger length dependency', () => {
     const array = new Array(3)
     const observed = reactive(array)
-    const fn = jest.fn()
+    const fn = vi.fn()
     effect(() => {
       fn(observed.length)
     })
@@ -114,7 +115,7 @@ describe('reactivity/reactive/Array', () => {
   test('add non-integer prop on Array should not trigger length dependency', () => {
     const array: any[] & { x?: string } = new Array(3)
     const observed = reactive(array)
-    const fn = jest.fn()
+    const fn = vi.fn()
     effect(() => {
       fn(observed.length)
     })
index 76add567d890bc42580aca389e8399c0a5713656..646cc6e6791bebf88424734452ddd08aa2b9fa25 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ref,
   effect,
@@ -385,7 +386,7 @@ describe('reactivity/ref', () => {
     const obj = reactive({ count: 0 })
 
     const a = ref(obj)
-    const spy1 = jest.fn(() => a.value)
+    const spy1 = vi.fn(() => a.value)
 
     effect(spy1)
 
@@ -393,7 +394,7 @@ describe('reactivity/ref', () => {
     expect(spy1).toBeCalledTimes(1)
 
     const b = shallowRef(obj)
-    const spy2 = jest.fn(() => b.value)
+    const spy2 = vi.fn(() => b.value)
 
     effect(spy2)
 
index 4d39fa9b393358ee381e6d9ad0dfcc5947b6aa33..297f0dc33c96a2f2db22d8559d76aaf20060db14 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   isReactive,
   isShallow,
@@ -125,7 +126,7 @@ describe('shallowReactive', () => {
 
     // #1210
     test('onTrack on called on objectSpread', () => {
-      const onTrackFn = jest.fn()
+      const onTrackFn = vi.fn()
       const shallowSet = shallowReactive(new Set())
       let a
       effect(
@@ -170,7 +171,7 @@ describe('shallowReactive', () => {
     })
 
     test('onTrack on called on objectSpread', () => {
-      const onTrackFn = jest.fn()
+      const onTrackFn = vi.fn()
       const shallowArray = shallowReactive([])
       let a
       effect(
index 45b82923dbab0981328d675dc564b97853d047b8..a63a950c60a2ca839fe37ea25faf45f7f60f90bc 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   defineAsyncComponent,
   h,
@@ -137,7 +138,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => (toggle.value ? h(Foo) : null)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
 
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
@@ -182,7 +183,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => (toggle.value ? h(Foo) : null)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
 
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
@@ -273,7 +274,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => (toggle.value ? h(Foo) : null)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
 
     app.mount(root)
 
@@ -324,7 +325,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => h(Foo)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
 
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
@@ -358,7 +359,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => h(Foo)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
 
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
@@ -390,7 +391,7 @@ describe('api: defineAsyncComponent', () => {
     const app = createApp({
       render: () => h(Foo)
     })
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
     await timeout(1)
@@ -421,7 +422,7 @@ describe('api: defineAsyncComponent', () => {
     const app = createApp({
       render: () => h(Foo)
     })
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
     await timeout(1)
@@ -512,7 +513,7 @@ describe('api: defineAsyncComponent', () => {
         })
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('loading')
 
@@ -549,7 +550,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => h(Foo)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
     expect(loaderCallCount).toBe(1)
@@ -593,7 +594,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => h(Foo)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
     expect(loaderCallCount).toBe(1)
@@ -633,7 +634,7 @@ describe('api: defineAsyncComponent', () => {
       render: () => h(Foo)
     })
 
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
     expect(serializeInner(root)).toBe('<!---->')
     expect(loaderCallCount).toBe(1)
@@ -758,12 +759,12 @@ describe('api: defineAsyncComponent', () => {
     const updater = ref(0)
 
     const vnodeHooks = {
-      onVnodeBeforeMount: jest.fn(),
-      onVnodeMounted: jest.fn(),
-      onVnodeBeforeUpdate: jest.fn(),
-      onVnodeUpdated: jest.fn(),
-      onVnodeBeforeUnmount: jest.fn(),
-      onVnodeUnmounted: jest.fn()
+      onVnodeBeforeMount: vi.fn(),
+      onVnodeMounted: vi.fn(),
+      onVnodeBeforeUpdate: vi.fn(),
+      onVnodeUpdated: vi.fn(),
+      onVnodeBeforeUnmount: vi.fn(),
+      onVnodeUnmounted: vi.fn()
     }
 
     const toggle = ref(true)
@@ -803,7 +804,7 @@ describe('api: defineAsyncComponent', () => {
   })
 
   test('with KeepAlive', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     let resolve: (comp: Component) => void
 
     const Foo = defineAsyncComponent(
index 3fb5bb17529aa194ef33460f5c9a44c70a25cf0c..7cfce51c1619553cf4c3a737303886b641f1fbea 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   createApp,
   h,
@@ -145,9 +146,9 @@ describe('api: createApp', () => {
   })
 
   test('directive', () => {
-    const spy1 = jest.fn()
-    const spy2 = jest.fn()
-    const spy3 = jest.fn()
+    const spy1 = vi.fn()
+    const spy2 = vi.fn()
+    const spy3 = vi.fn()
 
     const Root = {
       // local override
@@ -322,7 +323,7 @@ describe('api: createApp', () => {
     const error = new Error()
     const count = ref(0)
 
-    const handler = jest.fn((err, instance, info) => {
+    const handler = vi.fn((err, instance, info) => {
       expect(err).toBe(error)
       expect((instance as any).count).toBe(count.value)
       expect(info).toBe(`render function`)
@@ -348,7 +349,7 @@ describe('api: createApp', () => {
 
   test('config.warnHandler', () => {
     let ctx: any
-    const handler = jest.fn((msg, instance, trace) => {
+    const handler = vi.fn((msg, instance, trace) => {
       expect(msg).toMatch(`Component is missing template or render function`)
       expect(instance).toBe(ctx.proxy)
       expect(trace).toMatch(`Hello`)
@@ -368,7 +369,7 @@ describe('api: createApp', () => {
   })
 
   describe('config.isNativeTag', () => {
-    const isNativeTag = jest.fn(tag => tag === 'div')
+    const isNativeTag = vi.fn(tag => tag === 'div')
 
     test('Component.name', () => {
       const Root = {
index b7e8de30d55a3b2c5d2d48014e934245faa98c9d..40cf0764453781bdf433e4c6dc2d432ea5b4b1da 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   onBeforeMount,
   h,
@@ -23,7 +24,7 @@ import { ITERATE_KEY, DebuggerEvent, TriggerOpTypes } from '@vue/reactivity'
 describe('api: lifecycle hooks', () => {
   it('onBeforeMount', () => {
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called before inner div is rendered
       expect(serializeInner(root)).toBe(``)
     })
@@ -40,7 +41,7 @@ describe('api: lifecycle hooks', () => {
 
   it('onMounted', () => {
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called after inner div is rendered
       expect(serializeInner(root)).toBe(`<div></div>`)
     })
@@ -58,7 +59,7 @@ describe('api: lifecycle hooks', () => {
   it('onBeforeUpdate', async () => {
     const count = ref(0)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called before inner div is updated
       expect(serializeInner(root)).toBe(`<div>0</div>`)
     })
@@ -80,12 +81,12 @@ describe('api: lifecycle hooks', () => {
   it('state mutation in onBeforeUpdate', async () => {
     const count = ref(0)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called before inner div is updated
       expect(serializeInner(root)).toBe(`<div>0</div>`)
       count.value++
     })
-    const renderSpy = jest.fn()
+    const renderSpy = vi.fn()
 
     const Comp = {
       setup() {
@@ -109,7 +110,7 @@ describe('api: lifecycle hooks', () => {
   it('onUpdated', async () => {
     const count = ref(0)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called after inner div is updated
       expect(serializeInner(root)).toBe(`<div>1</div>`)
     })
@@ -130,7 +131,7 @@ describe('api: lifecycle hooks', () => {
   it('onBeforeUnmount', async () => {
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called before inner div is removed
       expect(serializeInner(root)).toBe(`<div></div>`)
     })
@@ -158,7 +159,7 @@ describe('api: lifecycle hooks', () => {
   it('onUnmounted', async () => {
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called after inner div is removed
       expect(serializeInner(root)).toBe(`<!---->`)
     })
@@ -186,7 +187,7 @@ describe('api: lifecycle hooks', () => {
   it('onBeforeUnmount in onMounted', async () => {
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
-    const fn = jest.fn(() => {
+    const fn = vi.fn(() => {
       // should be called before inner div is removed
       expect(serializeInner(root)).toBe(`<div></div>`)
     })
@@ -297,7 +298,7 @@ describe('api: lifecycle hooks', () => {
 
   it('onRenderTracked', () => {
     const events: DebuggerEvent[] = []
-    const onTrack = jest.fn((e: DebuggerEvent) => {
+    const onTrack = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive({ foo: 1, bar: 2 })
@@ -333,7 +334,7 @@ describe('api: lifecycle hooks', () => {
 
   it('onRenderTriggered', async () => {
     const events: DebuggerEvent[] = []
-    const onTrigger = jest.fn((e: DebuggerEvent) => {
+    const onTrigger = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive<{
@@ -380,7 +381,7 @@ describe('api: lifecycle hooks', () => {
   })
 
   it('runs shared hook fn for each instance', async () => {
-    const fn = jest.fn()
+    const fn = vi.fn()
     const toggle = ref(true)
     const Comp = {
       setup() {
index 96601b7870fc88672e6dff3c5942d884c06484e5..14c7f3852d750399bcef2e5691912f2e04488d03 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   nodeOps,
@@ -140,11 +141,11 @@ describe('api: options', () => {
     function returnThis(this: any) {
       return this
     }
-    const spyA = jest.fn(returnThis)
-    const spyB = jest.fn(returnThis)
-    const spyC = jest.fn(returnThis)
-    const spyD = jest.fn(returnThis)
-    const spyE = jest.fn(returnThis)
+    const spyA = vi.fn(returnThis)
+    const spyB = vi.fn(returnThis)
+    const spyC = vi.fn(returnThis)
+    const spyD = vi.fn(returnThis)
+    const spyE = vi.fn(returnThis)
 
     let ctx: any
     const Comp = {
@@ -186,7 +187,7 @@ describe('api: options', () => {
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
 
-    function assertCall(spy: jest.Mock, callIndex: number, args: any[]) {
+    function assertCall(spy: vi.Mock, callIndex: number, args: any[]) {
       expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
       expect(spy).toHaveReturnedWith(ctx)
     }
@@ -222,9 +223,9 @@ describe('api: options', () => {
     function returnThis(this: any) {
       return this
     }
-    const spyA = jest.fn(returnThis)
-    const spyB = jest.fn(returnThis)
-    const spyC = jest.fn(returnThis)
+    const spyA = vi.fn(returnThis)
+    const spyB = vi.fn(returnThis)
+    const spyC = vi.fn(returnThis)
 
     let ctx: any
     const Comp = {
@@ -259,7 +260,7 @@ describe('api: options', () => {
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
 
-    function assertCall(spy: jest.Mock, callIndex: number, args: any[]) {
+    function assertCall(spy: vi.Mock, callIndex: number, args: any[]) {
       expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
       expect(spy).toHaveReturnedWith(ctx)
     }
@@ -1120,7 +1121,7 @@ describe('api: options', () => {
       methods: {}
     }
 
-    const watchSpy = jest.fn()
+    const watchSpy = vi.fn()
     const mixin2 = {
       watch: {
         mixin3Data: watchSpy
index f00abc9c1c83d8e9d72422599b503b7f6fd27ea2..a7dbe3e03c02b66a9c1c27e79dba4351023d9b26 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { ref, reactive } from '@vue/reactivity'
 import {
   renderToString,
@@ -169,7 +170,7 @@ describe('api: setup context', () => {
 
   it('context.emit', async () => {
     const count = ref(0)
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     const Parent = {
       render: () =>
index e9dd1717bb25d641a830478d465ec63f3f51967e..ca0759cade3328459931da24532390b45827e19e 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ComponentInternalInstance,
   createApp,
@@ -149,7 +150,7 @@ describe('SFC <script setup> helpers', () => {
     })
 
     test('basic', async () => {
-      const spy = jest.fn()
+      const spy = vi.fn()
 
       let beforeInstance: ComponentInternalInstance | null = null
       let afterInstance: ComponentInternalInstance | null = null
@@ -197,7 +198,7 @@ describe('SFC <script setup> helpers', () => {
     })
 
     test('error handling', async () => {
-      const spy = jest.fn()
+      const spy = vi.fn()
 
       let beforeInstance: ComponentInternalInstance | null = null
       let afterInstance: ComponentInternalInstance | null = null
index 7ae72cce7fb87ac5e10279183db6e01005caf875..45ced8947e2f19b426057b3b0b7463668cf7f065 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   watch,
   watchEffect,
@@ -85,7 +86,7 @@ describe('api: watch', () => {
 
   it('watching single source: array', async () => {
     const array = reactive([] as number[])
-    const spy = jest.fn()
+    const spy = vi.fn()
     watch(array, spy)
     array.push(1)
     await nextTick()
@@ -94,7 +95,7 @@ describe('api: watch', () => {
   })
 
   it('should not fire if watched getter result did not change', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const n = ref(0)
     watch(() => n.value % 2, spy)
 
@@ -279,7 +280,7 @@ describe('api: watch', () => {
 
   it('cleanup registration (effect)', async () => {
     const state = reactive({ count: 0 })
-    const cleanup = jest.fn()
+    const cleanup = vi.fn()
     let dummy
     const stop = watchEffect(onCleanup => {
       onCleanup(cleanup)
@@ -298,7 +299,7 @@ describe('api: watch', () => {
 
   it('cleanup registration (with source)', async () => {
     const count = ref(0)
-    const cleanup = jest.fn()
+    const cleanup = vi.fn()
     let dummy
     const stop = watch(count, (count, prevCount, onCleanup) => {
       onCleanup(cleanup)
@@ -326,7 +327,7 @@ describe('api: watch', () => {
     let callCount = 0
     let result1
     let result2
-    const assertion = jest.fn((count, count2Value) => {
+    const assertion = vi.fn((count, count2Value) => {
       callCount++
       // on mount, the watcher callback should be called before DOM render
       // on update, should be called before the count is updated
@@ -364,7 +365,7 @@ describe('api: watch', () => {
   it('flush timing: post', async () => {
     const count = ref(0)
     let result
-    const assertion = jest.fn(count => {
+    const assertion = vi.fn(count => {
       result = serializeInner(root) === `${count}`
     })
 
@@ -393,7 +394,7 @@ describe('api: watch', () => {
   it('watchPostEffect', async () => {
     const count = ref(0)
     let result
-    const assertion = jest.fn(count => {
+    const assertion = vi.fn(count => {
       result = serializeInner(root) === `${count}`
     })
 
@@ -423,7 +424,7 @@ describe('api: watch', () => {
     let callCount = 0
     let result1
     let result2
-    const assertion = jest.fn(count => {
+    const assertion = vi.fn(count => {
       callCount++
       // on mount, the watcher callback should be called before DOM render
       // on update, should be called before the count is updated
@@ -470,7 +471,7 @@ describe('api: watch', () => {
     let callCount = 0
     let result1
     let result2
-    const assertion = jest.fn(count => {
+    const assertion = vi.fn(count => {
       callCount++
       // on mount, the watcher callback should be called before DOM render
       // on update, should be called before the count is updated
@@ -507,7 +508,7 @@ describe('api: watch', () => {
 
   it('should not fire on component unmount w/ flush: post', async () => {
     const toggle = ref(true)
-    const cb = jest.fn()
+    const cb = vi.fn()
     const Comp = {
       setup() {
         watch(toggle, cb, { flush: 'post' })
@@ -529,7 +530,7 @@ describe('api: watch', () => {
   // #2291
   it('should not fire on component unmount w/ flush: pre', async () => {
     const toggle = ref(true)
-    const cb = jest.fn()
+    const cb = vi.fn()
     const Comp = {
       setup() {
         watch(toggle, cb, { flush: 'pre' })
@@ -726,7 +727,7 @@ describe('api: watch', () => {
 
   it('immediate', async () => {
     const count = ref(0)
-    const cb = jest.fn()
+    const cb = vi.fn()
     watch(count, cb, { immediate: true })
     expect(cb).toHaveBeenCalledTimes(1)
     count.value++
@@ -736,14 +737,14 @@ describe('api: watch', () => {
 
   it('immediate: triggers when initial value is null', async () => {
     const state = ref(null)
-    const spy = jest.fn()
+    const spy = vi.fn()
     watch(() => state.value, spy, { immediate: true })
     expect(spy).toHaveBeenCalled()
   })
 
   it('immediate: triggers when initial value is undefined', async () => {
     const state = ref()
-    const spy = jest.fn()
+    const spy = vi.fn()
     watch(() => state.value, spy, { immediate: true })
     expect(spy).toHaveBeenCalledWith(undefined, undefined, expect.any(Function))
     state.value = 3
@@ -779,7 +780,7 @@ describe('api: watch', () => {
 
   it('warn and not respect deep option when using effect', async () => {
     const arr = ref([1, [2]])
-    const spy = jest.fn()
+    const spy = vi.fn()
     watchEffect(
       () => {
         spy()
@@ -798,7 +799,7 @@ describe('api: watch', () => {
   it('onTrack', async () => {
     const events: DebuggerEvent[] = []
     let dummy
-    const onTrack = jest.fn((e: DebuggerEvent) => {
+    const onTrack = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive({ foo: 1, bar: 2 })
@@ -833,7 +834,7 @@ describe('api: watch', () => {
   it('onTrigger', async () => {
     const events: DebuggerEvent[] = []
     let dummy
-    const onTrigger = jest.fn((e: DebuggerEvent) => {
+    const onTrigger = vi.fn((e: DebuggerEvent) => {
       events.push(e)
     })
     const obj = reactive<{ foo?: number }>({ foo: 1 })
@@ -912,7 +913,7 @@ describe('api: watch', () => {
 
   test('should force trigger on triggerRef when watching multiple sources: shallow ref array', async () => {
     const v = shallowRef([] as any)
-    const spy = jest.fn()
+    const spy = vi.fn()
     watch([v], () => {
       spy()
     })
@@ -927,7 +928,7 @@ describe('api: watch', () => {
 
   // #2125
   test('watchEffect should not recursively trigger itself', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const price = ref(10)
     const history = ref<number[]>([])
     watchEffect(() => {
@@ -940,7 +941,7 @@ describe('api: watch', () => {
 
   // #2231
   test('computed refs should not trigger watch if value has no change', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const source = ref(0)
     const price = computed(() => source.value === 0)
     watch(price, spy)
@@ -1005,7 +1006,7 @@ describe('api: watch', () => {
 
   test('this.$watch should pass `this.proxy` to watch source as the first argument ', () => {
     let instance: any
-    const source = jest.fn()
+    const source = vi.fn()
 
     const Comp = defineComponent({
       render() {},
@@ -1023,7 +1024,7 @@ describe('api: watch', () => {
   })
 
   test('should not leak `this.proxy` to setup()', () => {
-    const source = jest.fn()
+    const source = vi.fn()
 
     const Comp = defineComponent({
       render() {},
@@ -1042,7 +1043,7 @@ describe('api: watch', () => {
   test('pre watcher callbacks should not track dependencies', async () => {
     const a = ref(0)
     const b = ref(0)
-    const updated = jest.fn()
+    const updated = vi.fn()
 
     const Child = defineComponent({
       props: ['a'],
@@ -1077,7 +1078,7 @@ describe('api: watch', () => {
   })
 
   test('watching keypath', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const Comp = defineComponent({
       render() {},
       data() {
@@ -1107,7 +1108,7 @@ describe('api: watch', () => {
 
   it('watching sources: ref<any[]>', async () => {
     const foo = ref([1])
-    const spy = jest.fn()
+    const spy = vi.fn()
     watch(foo, () => {
       spy()
     })
index 558a42b04965b84245795f126e2a20c69b526e3d..0e5f1e3983d66ebd53bbee7911079c57399eb6e3 100644 (file)
@@ -1,6 +1,7 @@
 // Note: emits and listener fallthrough is tested in
 // ./rendererAttrsFallthrough.spec.ts.
 
+import { vi } from 'vitest'
 import {
   render,
   defineComponent,
@@ -23,9 +24,9 @@ describe('component: emit', () => {
       }
     })
 
-    const onfoo = jest.fn()
-    const onBar = jest.fn()
-    const onBaz = jest.fn()
+    const onfoo = vi.fn()
+    const onBar = vi.fn()
+    const onBaz = vi.fn()
     const Comp = () => h(Foo, { onfoo, onBar, ['on!baz']: onBaz })
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -43,7 +44,7 @@ describe('component: emit', () => {
       }
     })
 
-    const fooSpy = jest.fn()
+    const fooSpy = vi.fn()
     const Comp = () =>
       h(Foo, {
         onTestEvent: fooSpy
@@ -61,7 +62,7 @@ describe('component: emit', () => {
       }
     })
 
-    const fooSpy = jest.fn()
+    const fooSpy = vi.fn()
     const Comp = () =>
       h(Foo, {
         'onTest-event': fooSpy
@@ -81,8 +82,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fooSpy = jest.fn()
-    const barSpy = jest.fn()
+    const fooSpy = vi.fn()
+    const barSpy = vi.fn()
     const Comp = () =>
       // simulate v-on="obj" usage
       h(
@@ -108,8 +109,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fooSpy = jest.fn()
-    const barSpy = jest.fn()
+    const fooSpy = vi.fn()
+    const barSpy = vi.fn()
     const Comp = () =>
       h(Foo, {
         'onUpdate:fooProp': fooSpy,
@@ -129,8 +130,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const App = {
       setup() {
@@ -256,8 +257,8 @@ describe('component: emit', () => {
         this.$emit('bar')
       }
     })
-    const fn = jest.fn()
-    const barFn = jest.fn()
+    const fn = vi.fn()
+    const barFn = vi.fn()
     render(
       h(Foo, {
         onFooOnce: fn,
@@ -280,8 +281,8 @@ describe('component: emit', () => {
         this.$emit('foo')
       }
     })
-    const onFoo = jest.fn()
-    const onFooOnce = jest.fn()
+    const onFoo = vi.fn()
+    const onFooOnce = vi.fn()
     render(
       h(Foo, {
         onFoo,
@@ -302,8 +303,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const Comp = () =>
       h(Foo, {
@@ -333,8 +334,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const Comp = () =>
       h(Foo, {
@@ -364,8 +365,8 @@ describe('component: emit', () => {
       }
     })
 
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const Comp = () =>
       h(Foo, {
@@ -394,7 +395,7 @@ describe('component: emit', () => {
       }
     })
 
-    const fn = jest.fn()
+    const fn = vi.fn()
     const Comp = () =>
       h(Foo, {
         modelValue: null,
@@ -430,7 +431,7 @@ describe('component: emit', () => {
   })
 
   test('does not emit after unmount', async () => {
-    const fn = jest.fn()
+    const fn = vi.fn()
     const Foo = defineComponent({
       emits: ['closing'],
       async beforeUnmount() {
index 9763b22d3fb431dbf2c43a74c80e0ca4099e6e26..64da57e0d52d1cae4a4a482e78ee50b57b45f78c 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ComponentInternalInstance,
   getCurrentInstance,
@@ -163,8 +164,8 @@ describe('component props', () => {
 
   test('default value', () => {
     let proxy: any
-    const defaultFn = jest.fn(() => ({ a: 1 }))
-    const defaultBaz = jest.fn(() => ({ b: 1 }))
+    const defaultFn = vi.fn(() => ({ a: 1 }))
+    const defaultBaz = vi.fn(() => ({ b: 1 }))
 
     const Comp = {
       props: {
@@ -536,7 +537,7 @@ describe('component props', () => {
   // #3288
   test('declared prop key should be present even if not passed', async () => {
     let initialKeys: string[] = []
-    const changeSpy = jest.fn()
+    const changeSpy = vi.fn()
     const passFoo = ref(false)
 
     const Comp = {
index d3a4cef93f76ccfd52ce685587729add92fd97a5..f1379e65ca522792e4c44eab0215c2a05063b9b4 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   render,
@@ -306,7 +307,7 @@ describe('component: proxy', () => {
 
     // attaching jest spy, triggers the getter once, cache it and override the property.
     // also uses Object.defineProperty
-    const spy = jest.spyOn(instanceProxy, 'toggle')
+    const spy = vi.spyOn(instanceProxy, 'toggle')
     expect(getCalledTimes).toEqual(3)
 
     // expect getter to not evaluate the jest spy caches its value
index 9248a8e6afeb167ad9965f8a6c7a8175cf5de0af..b5d00d06992fb0880b3ec35d34769b3d77345242 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ref,
   render,
@@ -200,7 +201,7 @@ describe('component: slots', () => {
   test('should respect $stable flag', async () => {
     const flag1 = ref(1)
     const flag2 = ref(2)
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     const Child = () => {
       spy()
index f0e49f2671e2f96e84c0429facaeb00b2b25f4e0..b68562adb087336dc6588cc0921f4c27b15e449f 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   nodeOps,
   render,
@@ -44,28 +45,28 @@ function mockProps(extra: BaseTransitionProps = {}, withKeepAlive = false) {
     doneLeave: {}
   }
   const props: BaseTransitionProps = {
-    onBeforeEnter: jest.fn(el => {
+    onBeforeEnter: vi.fn(el => {
       if (!extra.persisted && !withKeepAlive) {
         expect(el.parentNode).toBeNull()
       }
     }),
-    onEnter: jest.fn((el, done) => {
+    onEnter: vi.fn((el, done) => {
       cbs.doneEnter[serialize(el as TestElement)] = done
     }),
-    onAfterEnter: jest.fn(),
-    onEnterCancelled: jest.fn(),
-    onBeforeLeave: jest.fn(),
-    onLeave: jest.fn((el, done) => {
+    onAfterEnter: vi.fn(),
+    onEnterCancelled: vi.fn(),
+    onBeforeLeave: vi.fn(),
+    onLeave: vi.fn((el, done) => {
       cbs.doneLeave[serialize(el as TestElement)] = done
     }),
-    onAfterLeave: jest.fn(),
-    onLeaveCancelled: jest.fn(),
-    onBeforeAppear: jest.fn(),
-    onAppear: jest.fn((el, done) => {
+    onAfterLeave: vi.fn(),
+    onLeaveCancelled: vi.fn(),
+    onBeforeAppear: vi.fn(),
+    onAppear: vi.fn((el, done) => {
       cbs.doneEnter[serialize(el as TestElement)] = done
     }),
-    onAfterAppear: jest.fn(),
-    onAppearCancelled: jest.fn(),
+    onAfterAppear: vi.fn(),
+    onAppearCancelled: vi.fn(),
     ...extra
   }
   return {
@@ -86,7 +87,7 @@ function assertCalls(
 }
 
 function assertCalledWithEl(fn: any, expected: string, callIndex = 0) {
-  expect(serialize((fn as jest.Mock).mock.calls[callIndex][0])).toBe(expected)
+  expect(serialize((fn as vi.Mock).mock.calls[callIndex][0])).toBe(expected)
 }
 
 interface ToggleOptions {
index 79e7811723a621b9b0eaa58223db037068ab2f79..344fba156c355c4aceecfdf01f99445af8bfab89 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   TestElement,
@@ -43,11 +44,11 @@ describe('KeepAlive', () => {
       render(this: any) {
         return h('div', this.msg)
       },
-      created: jest.fn(),
-      mounted: jest.fn(),
-      activated: jest.fn(),
-      deactivated: jest.fn(),
-      unmounted: jest.fn()
+      created: vi.fn(),
+      mounted: vi.fn(),
+      activated: vi.fn(),
+      deactivated: vi.fn(),
+      unmounted: vi.fn()
     }
     two = {
       name: 'two',
@@ -55,11 +56,11 @@ describe('KeepAlive', () => {
       render(this: any) {
         return h('div', this.msg)
       },
-      created: jest.fn(),
-      mounted: jest.fn(),
-      activated: jest.fn(),
-      deactivated: jest.fn(),
-      unmounted: jest.fn()
+      created: vi.fn(),
+      mounted: vi.fn(),
+      activated: vi.fn(),
+      deactivated: vi.fn(),
+      unmounted: vi.fn()
     }
     views = {
       one,
@@ -225,7 +226,7 @@ describe('KeepAlive', () => {
       render(this: any) {
         return h('div', this.msg)
       },
-      activated: jest.fn()
+      activated: vi.fn()
     }
     const one = {
       name: 'one',
@@ -399,18 +400,18 @@ describe('KeepAlive', () => {
     })
 
     test('max', async () => {
-      const spyAC = jest.fn()
-      const spyBC = jest.fn()
-      const spyCC = jest.fn()
-      const spyAA = jest.fn()
-      const spyBA = jest.fn()
-      const spyCA = jest.fn()
-      const spyADA = jest.fn()
-      const spyBDA = jest.fn()
-      const spyCDA = jest.fn()
-      const spyAUM = jest.fn()
-      const spyBUM = jest.fn()
-      const spyCUM = jest.fn()
+      const spyAC = vi.fn()
+      const spyBC = vi.fn()
+      const spyCC = vi.fn()
+      const spyAA = vi.fn()
+      const spyBA = vi.fn()
+      const spyCA = vi.fn()
+      const spyADA = vi.fn()
+      const spyBDA = vi.fn()
+      const spyCDA = vi.fn()
+      const spyAUM = vi.fn()
+      const spyBUM = vi.fn()
+      const spyCUM = vi.fn()
 
       function assertCount(calls: number[]) {
         expect([
@@ -609,13 +610,13 @@ describe('KeepAlive', () => {
     async function assertAnonymous(include: boolean) {
       const one = {
         name: 'one',
-        created: jest.fn(),
+        created: vi.fn(),
         render: () => 'one'
       }
 
       const two = {
         // anonymous
-        created: jest.fn(),
+        created: vi.fn(),
         render: () => 'two'
       }
 
@@ -670,7 +671,7 @@ describe('KeepAlive', () => {
     test('should not destroy active instance when pruning cache', async () => {
       const Foo = {
         render: () => 'foo',
-        unmounted: jest.fn()
+        unmounted: vi.fn()
       }
       const includeRef = ref(['foo'])
       const App = {
@@ -735,8 +736,8 @@ describe('KeepAlive', () => {
       }
     })
 
-    const spyMounted = jest.fn()
-    const spyUnmounted = jest.fn()
+    const spyMounted = vi.fn()
+    const spyUnmounted = vi.fn()
 
     const RouterView = defineComponent({
       setup(_, { slots }) {
@@ -885,7 +886,7 @@ describe('KeepAlive', () => {
   // #4976
   test('handle error in async onActivated', async () => {
     const err = new Error('foo')
-    const handler = jest.fn()
+    const handler = vi.fn()
 
     const app = createApp({
       setup() {
@@ -911,12 +912,12 @@ describe('KeepAlive', () => {
 
   // #3648
   test('should avoid unmount later included components', async () => {
-    const unmountedA = jest.fn()
-    const mountedA = jest.fn()
-    const activatedA = jest.fn()
-    const deactivatedA = jest.fn()
-    const unmountedB = jest.fn()
-    const mountedB = jest.fn()
+    const unmountedA = vi.fn()
+    const mountedA = vi.fn()
+    const activatedA = vi.fn()
+    const deactivatedA = vi.fn()
+    const unmountedB = vi.fn()
+    const mountedB = vi.fn()
 
     const A = {
       name: 'A',
index a2c38b2846e11b8f1b4f1b52bbbea249f755ca9b..f71d6bf1efe76d297301cbe9b588cc7cd8725643 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   ref,
@@ -76,9 +77,9 @@ describe('Suspense', () => {
       }
     })
 
-    const onFallback = jest.fn()
-    const onResolve = jest.fn()
-    const onPending = jest.fn()
+    const onFallback = vi.fn()
+    const onResolve = vi.fn()
+    const onPending = vi.fn()
 
     const show = ref(true)
     const Comp = {
@@ -190,7 +191,7 @@ describe('Suspense', () => {
       }
     })
 
-    const onResolve = jest.fn()
+    const onResolve = vi.fn()
 
     const Comp = {
       setup() {
@@ -451,7 +452,7 @@ describe('Suspense', () => {
 
   test('unmount suspense after resolve', async () => {
     const toggle = ref(true)
-    const unmounted = jest.fn()
+    const unmounted = vi.fn()
 
     const Async = defineAsyncComponent({
       setup() {
@@ -489,8 +490,8 @@ describe('Suspense', () => {
 
   test('unmount suspense before resolve', async () => {
     const toggle = ref(true)
-    const mounted = jest.fn()
-    const unmounted = jest.fn()
+    const mounted = vi.fn()
+    const unmounted = vi.fn()
 
     const Async = defineAsyncComponent({
       setup() {
index e5f76e307002abf8f302e759d0ef64a88e1cd74a..b9ae3a8a42dba674aa76ae4fc6d356e449a941c4 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   nodeOps,
   serializeInner,
@@ -440,8 +441,8 @@ describe('renderer: teleport', () => {
     const root = nodeOps.createElement('div')
     const toggle = ref(true)
     const dir = {
-      mounted: jest.fn(),
-      unmounted: jest.fn()
+      mounted: vi.fn(),
+      unmounted: vi.fn()
     }
 
     const app = createApp({
index dcf429bb72eebb2c2ff3aa546b23e8a608c366f1..70578f94453b93fa8fb449ee6ad7cbf44018fb84 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   withDirectives,
@@ -23,7 +24,7 @@ describe('directives', () => {
       expect(binding.modifiers && binding.modifiers.ok).toBe(true)
     }
 
-    const beforeMount = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeMount = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should not be inserted yet
       expect(el.parentNode).toBe(null)
@@ -35,7 +36,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const mounted = jest.fn(((el, binding, vnode, prevVNode) => {
+    const mounted = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should be inserted now
       expect(el.parentNode).toBe(root)
@@ -47,7 +48,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const beforeUpdate = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeUpdate = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       expect(el.parentNode).toBe(root)
       expect(root.children[0]).toBe(el)
@@ -61,7 +62,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(_prevVnode)
     }) as DirectiveHook)
 
-    const updated = jest.fn(((el, binding, vnode, prevVNode) => {
+    const updated = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       expect(el.parentNode).toBe(root)
       expect(root.children[0]).toBe(el)
@@ -75,7 +76,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(_prevVnode)
     }) as DirectiveHook)
 
-    const beforeUnmount = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeUnmount = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should be removed now
       expect(el.parentNode).toBe(root)
@@ -87,7 +88,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const unmounted = jest.fn(((el, binding, vnode, prevVNode) => {
+    const unmounted = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should have been removed
       expect(el.parentNode).toBe(null)
@@ -158,7 +159,7 @@ describe('directives', () => {
       expect(binding.modifiers && binding.modifiers.ok).toBe(true)
     }
 
-    const fn = jest.fn(((el, binding, vnode, prevVNode) => {
+    const fn = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       expect(el.parentNode).toBe(root)
 
@@ -212,7 +213,7 @@ describe('directives', () => {
       expect(binding.modifiers && binding.modifiers.ok).toBe(true)
     }
 
-    const beforeMount = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeMount = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should not be inserted yet
       expect(el.parentNode).toBe(null)
@@ -224,7 +225,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const mounted = jest.fn(((el, binding, vnode, prevVNode) => {
+    const mounted = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should be inserted now
       expect(el.parentNode).toBe(root)
@@ -236,7 +237,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const beforeUpdate = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeUpdate = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       expect(el.parentNode).toBe(root)
       expect(root.children[0]).toBe(el)
@@ -250,7 +251,7 @@ describe('directives', () => {
       expect(prevVNode!.type).toBe(_prevVnode!.type)
     }) as DirectiveHook)
 
-    const updated = jest.fn(((el, binding, vnode, prevVNode) => {
+    const updated = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       expect(el.parentNode).toBe(root)
       expect(root.children[0]).toBe(el)
@@ -264,7 +265,7 @@ describe('directives', () => {
       expect(prevVNode!.type).toBe(_prevVnode!.type)
     }) as DirectiveHook)
 
-    const beforeUnmount = jest.fn(((el, binding, vnode, prevVNode) => {
+    const beforeUnmount = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should be removed now
       expect(el.parentNode).toBe(root)
@@ -276,7 +277,7 @@ describe('directives', () => {
       expect(prevVNode).toBe(null)
     }) as DirectiveHook)
 
-    const unmounted = jest.fn(((el, binding, vnode, prevVNode) => {
+    const unmounted = vi.fn(((el, binding, vnode, prevVNode) => {
       expect(el.tag).toBe('div')
       // should have been removed
       expect(el.parentNode).toBe(null)
@@ -345,10 +346,10 @@ describe('directives', () => {
   // #2298
   it('directive merging on component root', () => {
     const d1 = {
-      mounted: jest.fn()
+      mounted: vi.fn()
     }
     const d2 = {
-      mounted: jest.fn()
+      mounted: vi.fn()
     }
     const Comp = {
       render() {
@@ -372,7 +373,7 @@ describe('directives', () => {
   test('should disable tracking inside directive lifecycle hooks', async () => {
     const count = ref(0)
     const text = ref('')
-    const beforeUpdate = jest.fn(() => count.value++)
+    const beforeUpdate = vi.fn(() => count.value++)
 
     const App = {
       render() {
@@ -424,7 +425,7 @@ describe('directives', () => {
 
   test('should not throw with unknown directive', async () => {
     const d1 = {
-      mounted: jest.fn()
+      mounted: vi.fn()
     }
     const App = {
       name: 'App',
index 8a18870a5db3a927e5deda5c56e07d57bb31d752..e3a2495f0f99a1b6564382c02fe71c000c748556 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   onMounted,
   onErrorCaptured,
@@ -15,7 +16,7 @@ import {
 describe('error handling', () => {
   test('propagation', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -53,7 +54,7 @@ describe('error handling', () => {
 
   test('propagation stoppage', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -91,7 +92,7 @@ describe('error handling', () => {
 
   test('async error handling', async () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -121,7 +122,7 @@ describe('error handling', () => {
   test('error thrown in onErrorCaptured', () => {
     const err = new Error('foo')
     const err2 = new Error('bar')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -159,7 +160,7 @@ describe('error handling', () => {
 
   test('setup function', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -186,7 +187,7 @@ describe('error handling', () => {
   // the options API initialization process instead of by the renderer.
   test('in created/beforeCreate hook', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -219,7 +220,7 @@ describe('error handling', () => {
 
   test('in render function', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -248,7 +249,7 @@ describe('error handling', () => {
     const ref = () => {
       throw err
     }
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -268,7 +269,7 @@ describe('error handling', () => {
 
   test('in effect', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -295,7 +296,7 @@ describe('error handling', () => {
 
   test('in watch getter', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -325,7 +326,7 @@ describe('error handling', () => {
 
   test('in watch callback', async () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -360,7 +361,7 @@ describe('error handling', () => {
   test('in effect cleanup', async () => {
     const err = new Error('foo')
     const count = ref(0)
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -393,7 +394,7 @@ describe('error handling', () => {
 
   test('in component event handler via emit', () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -423,7 +424,7 @@ describe('error handling', () => {
 
   test('in component event handler via emit (async)', async () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -455,7 +456,7 @@ describe('error handling', () => {
 
   test('in component event handler via emit (async + array)', async () => {
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const res: Promise<any>[] = []
     const createAsyncHandler = (p: Promise<any>) => () => {
@@ -497,13 +498,13 @@ describe('error handling', () => {
   })
 
   it('should warn unhandled', () => {
-    const groupCollapsed = jest.spyOn(console, 'groupCollapsed')
+    const groupCollapsed = vi.spyOn(console, 'groupCollapsed')
     groupCollapsed.mockImplementation(() => {})
-    const log = jest.spyOn(console, 'log')
+    const log = vi.spyOn(console, 'log')
     log.mockImplementation(() => {})
 
     const err = new Error('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = {
       setup() {
@@ -543,7 +544,7 @@ describe('error handling', () => {
     const error2 = new Error('error2')
     const error3 = new Error('error3')
     const error4 = new Error('error4')
-    const handler = jest.fn()
+    const handler = vi.fn()
 
     const app = createApp({
       setup() {
index 4b501052ce43f0473873aca0c6baad9d888d6b33..d1392b78465a91f7eac309b53dda7491f9fd97c5 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { HMRRuntime } from '../src/hmr'
 import '../src/hmr'
 import { ComponentOptions, InternalRenderFunction } from '../src/component'
@@ -117,8 +118,8 @@ describe('hot module replacement', () => {
   test('reload', async () => {
     const root = nodeOps.createElement('div')
     const childId = 'test3-child'
-    const unmountSpy = jest.fn()
-    const mountSpy = jest.fn()
+    const unmountSpy = vi.fn()
+    const mountSpy = vi.fn()
 
     const Child: ComponentOptions = {
       __hmrId: childId,
@@ -155,10 +156,10 @@ describe('hot module replacement', () => {
   test('reload KeepAlive slot', async () => {
     const root = nodeOps.createElement('div')
     const childId = 'test-child-keep-alive'
-    const unmountSpy = jest.fn()
-    const mountSpy = jest.fn()
-    const activeSpy = jest.fn()
-    const deactiveSpy = jest.fn()
+    const unmountSpy = vi.fn()
+    const mountSpy = vi.fn()
+    const activeSpy = vi.fn()
+    const deactiveSpy = vi.fn()
 
     const Child: ComponentOptions = {
       __hmrId: childId,
@@ -221,8 +222,8 @@ describe('hot module replacement', () => {
   test('reload class component', async () => {
     const root = nodeOps.createElement('div')
     const childId = 'test4-child'
-    const unmountSpy = jest.fn()
-    const mountSpy = jest.fn()
+    const unmountSpy = vi.fn()
+    const mountSpy = vi.fn()
 
     class Child {
       static __vccOpts: ComponentOptions = {
@@ -467,8 +468,8 @@ describe('hot module replacement', () => {
   // #4174
   test('with global mixins', async () => {
     const childId = 'hmr-global-mixin'
-    const createSpy1 = jest.fn()
-    const createSpy2 = jest.fn()
+    const createSpy1 = vi.fn()
+    const createSpy2 = vi.fn()
 
     const Child: ComponentOptions = {
       __hmrId: childId,
index d88323051853f390cff55f0cfa2e66ffdf7f78cc..555ccf90d198787f9d96686109980136b17c6821 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   createSSRApp,
   h,
@@ -134,7 +135,7 @@ describe('SSR hydration', () => {
 
   test('element with elements children', async () => {
     const msg = ref('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const { vnode, container } = mountWithHydration(
       '<div><span>foo</span><span class="foo"></span></div>',
       () =>
@@ -171,7 +172,7 @@ describe('SSR hydration', () => {
 
   test('Fragment', async () => {
     const msg = ref('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const { vnode, container } = mountWithHydration(
       '<div><!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]--></div>',
       () =>
@@ -222,7 +223,7 @@ describe('SSR hydration', () => {
 
   test('Teleport', async () => {
     const msg = ref('foo')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const teleportContainer = document.createElement('div')
     teleportContainer.id = 'teleport'
     teleportContainer.innerHTML = `<span>foo</span><span class="foo"></span><!--teleport anchor-->`
@@ -262,8 +263,8 @@ describe('SSR hydration', () => {
 
   test('Teleport (multiple + integration)', async () => {
     const msg = ref('foo')
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const Comp = () => [
       h(Teleport, { to: '#teleport2' }, [
@@ -329,8 +330,8 @@ describe('SSR hydration', () => {
 
   test('Teleport (disabled)', async () => {
     const msg = ref('foo')
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     const Comp = () => [
       h('div', 'foo'),
@@ -453,7 +454,7 @@ describe('SSR hydration', () => {
   // compile SSR + client render fn from the same template & hydrate
   test('full compiler integration', async () => {
     const mounted: string[] = []
-    const log = jest.fn()
+    const log = vi.fn()
     const toggle = ref(true)
 
     const Child = {
@@ -564,7 +565,7 @@ describe('SSR hydration', () => {
     container.innerHTML = await renderToString(h(App))
     // hydrate
     const app = createSSRApp(App)
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(container)
     // assert interactions
     // parent button click
@@ -591,7 +592,7 @@ describe('SSR hydration', () => {
     container.innerHTML = await renderToString(h(App))
     // hydrate
     const app = createSSRApp(App)
-    const handler = (app.config.errorHandler = jest.fn())
+    const handler = (app.config.errorHandler = vi.fn())
     app.mount(container)
     // assert interactions
     // parent blur event
@@ -653,7 +654,7 @@ describe('SSR hydration', () => {
       }
     })
 
-    const done = jest.fn()
+    const done = vi.fn()
     const App = {
       template: `
       <Suspense @resolve="done">
@@ -710,7 +711,7 @@ describe('SSR hydration', () => {
   })
 
   test('async component', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const Comp = () =>
       h(
         'button',
index f23cdf6a27c46de5188d383eaf59ac017545f16d..6dd51b368dbc0672fb85dc6f4d451f36ecab6839 100644 (file)
@@ -1,4 +1,5 @@
 // using DOM renderer because this case is mostly DOM-specific
+import { vi } from 'vitest'
 import {
   h,
   render,
@@ -18,8 +19,8 @@ import { PatchFlags } from '@vue/shared/src'
 
 describe('attribute fallthrough', () => {
   it('should allow attrs to fallthrough', async () => {
-    const click = jest.fn()
-    const childUpdated = jest.fn()
+    const click = vi.fn()
+    const childUpdated = vi.fn()
 
     const Hello = {
       setup() {
@@ -83,8 +84,8 @@ describe('attribute fallthrough', () => {
   })
 
   it('should only allow whitelisted fallthrough on functional component with optional props', async () => {
-    const click = jest.fn()
-    const childUpdated = jest.fn()
+    const click = vi.fn()
+    const childUpdated = vi.fn()
 
     const count = ref(0)
 
@@ -141,8 +142,8 @@ describe('attribute fallthrough', () => {
   })
 
   it('should allow all attrs on functional component with declared props', async () => {
-    const click = jest.fn()
-    const childUpdated = jest.fn()
+    const click = vi.fn()
+    const childUpdated = vi.fn()
 
     const count = ref(0)
 
@@ -197,9 +198,9 @@ describe('attribute fallthrough', () => {
   })
 
   it('should fallthrough for nested components', async () => {
-    const click = jest.fn()
-    const childUpdated = jest.fn()
-    const grandChildUpdated = jest.fn()
+    const click = vi.fn()
+    const childUpdated = vi.fn()
+    const grandChildUpdated = vi.fn()
 
     const Hello = {
       setup() {
@@ -385,7 +386,7 @@ describe('attribute fallthrough', () => {
   })
 
   it('should dedupe same listeners when $attrs is used during render', () => {
-    const click = jest.fn()
+    const click = vi.fn()
     const count = ref(0)
 
     function inc() {
@@ -580,7 +581,7 @@ describe('attribute fallthrough', () => {
       }
     })
 
-    const onClick = jest.fn()
+    const onClick = vi.fn()
     const App = {
       render() {
         return h(Child, {
@@ -611,7 +612,7 @@ describe('attribute fallthrough', () => {
     }
     Child.emits = ['click']
 
-    const onClick = jest.fn()
+    const onClick = vi.fn()
     const App = {
       render() {
         return h(Child, {
@@ -631,7 +632,7 @@ describe('attribute fallthrough', () => {
   })
 
   it('should support fallthrough for fragments with single element + comments', () => {
-    const click = jest.fn()
+    const click = vi.fn()
 
     const Hello = {
       setup() {
@@ -673,7 +674,7 @@ describe('attribute fallthrough', () => {
   it('should not fallthrough v-model listeners with corresponding declared prop', () => {
     let textFoo = ''
     let textBar = ''
-    const click = jest.fn()
+    const click = vi.fn()
 
     const App = defineComponent({
       setup() {
index 3fdc388823dd91ddc4b23b2a126310d40b4494a2..02d8237673324f6f51452b8f11c96fad6b5449a9 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ref,
   h,
@@ -91,7 +92,7 @@ describe('renderer: component', () => {
   it('should not update Component if only changed props are declared emit listeners', () => {
     const Comp1 = {
       emits: ['foo'],
-      updated: jest.fn(),
+      updated: vi.fn(),
       render: () => null
     }
     const root = nodeOps.createElement('div')
@@ -145,8 +146,8 @@ describe('renderer: component', () => {
     function returnThis(this: any, _arg: any) {
       return this
     }
-    const propWatchSpy = jest.fn(returnThis)
-    const dataWatchSpy = jest.fn(returnThis)
+    const propWatchSpy = vi.fn(returnThis)
+    const dataWatchSpy = vi.fn(returnThis)
     let instance: any
     const Comp = {
       props: {
@@ -267,7 +268,7 @@ describe('renderer: component', () => {
       setup() {
         return () => h(Child)
       },
-      updated: jest.fn()
+      updated: vi.fn()
     }
 
     const root = nodeOps.createElement('div')
@@ -327,7 +328,7 @@ describe('renderer: component', () => {
 
   test('child component props update should not lead to double update', async () => {
     const text = ref(0)
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     const App = {
       render() {
index a1a3293c0328b3af4528b8a66dcc47860b3c0e30..492048173a44bca71f2d085b710c14a07d7c14b8 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   Fragment,
@@ -343,8 +344,8 @@ describe('renderer: optimized mode', () => {
   })
 
   test('PatchFlags: PatchFlags.NEED_PATCH', async () => {
-    const spyMounted = jest.fn()
-    const spyUpdated = jest.fn()
+    const spyMounted = vi.fn()
+    const spyUpdated = vi.fn()
     const count = ref(0)
     const Comp = {
       setup() {
@@ -469,7 +470,7 @@ describe('renderer: optimized mode', () => {
   // When unmounting (1), we know we are in optimized mode so no need to further
   // traverse unmount its children
   test('should not perform unnecessary unmount traversals', () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const Child = {
       setup() {
         onBeforeUnmount(spy)
@@ -490,8 +491,8 @@ describe('renderer: optimized mode', () => {
   // #2444
   // `KEYED_FRAGMENT` and `UNKEYED_FRAGMENT` always need to diff its children
   test('non-stable Fragment always need to diff its children', () => {
-    const spyA = jest.fn()
-    const spyB = jest.fn()
+    const spyA = vi.fn()
+    const spyB = vi.fn()
     const ChildA = {
       setup() {
         onBeforeUnmount(spyA)
@@ -830,7 +831,7 @@ describe('renderer: optimized mode', () => {
   // #4183
   test('should not take unmount children fast path /w Suspense', async () => {
     const show = ref(true)
-    const spyUnmounted = jest.fn()
+    const spyUnmounted = vi.fn()
 
     const Parent = {
       setup(props: any, { slots }: SetupContext) {
index 668391c9185b5e6e93114029e61bab3434e6f075..74265939ed25bf1003339dc78e0f81542ce4c7eb 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   ref,
   nodeOps,
@@ -83,7 +84,7 @@ describe('api: template refs', () => {
 
   it('function ref mount', () => {
     const root = nodeOps.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
 
     const Comp = defineComponent(() => () => h('div', { ref: fn }))
     render(h(Comp), root)
@@ -92,8 +93,8 @@ describe('api: template refs', () => {
 
   it('function ref update', async () => {
     const root = nodeOps.createElement('div')
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
     const fn = ref(fn1)
 
     const Comp = defineComponent(() => () => h('div', { ref: fn.value }))
@@ -112,7 +113,7 @@ describe('api: template refs', () => {
 
   it('function ref unmount', async () => {
     const root = nodeOps.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const toggle = ref(true)
 
     const Comp = defineComponent(
@@ -181,7 +182,7 @@ describe('api: template refs', () => {
 
   test('string ref inside slots', async () => {
     const root = nodeOps.createElement('div')
-    const spy = jest.fn()
+    const spy = vi.fn()
     const Child = {
       render(this: any) {
         return this.$slots.default()
@@ -273,7 +274,7 @@ describe('api: template refs', () => {
   // #1834
   test('exchange refs', async () => {
     const refToggle = ref(false)
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     const Comp = {
       render(this: any) {
@@ -304,7 +305,7 @@ describe('api: template refs', () => {
   // #1789
   test('toggle the same ref to different elements', async () => {
     const refToggle = ref(false)
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     const Comp = {
       render(this: any) {
index dc9bace9c9cba182613addb4535d6e4698094901..48bc469716c7ca224a392b7f69a2cb5d54aec7f1 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   queueJob,
   nextTick,
@@ -187,7 +188,7 @@ describe('scheduler', () => {
 
     // #3806
     it('queue preFlushCb inside postFlushCb', async () => {
-      const spy = jest.fn()
+      const spy = vi.fn()
       const cb = () => spy()
       cb.pre = true
       queuePostFlushCb(() => {
@@ -515,7 +516,7 @@ describe('scheduler', () => {
 
   // #910
   test('should not run stopped reactive effects', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
 
     // simulate parent component that toggles child
     const job1 = () => {
@@ -536,7 +537,7 @@ describe('scheduler', () => {
   })
 
   it('flushPreFlushCbs inside a pre job', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const job = () => {
       spy()
       flushPreFlushCbs()
index 54cdc725b4d2270c4ca86a6ec93e43ca8bde425f..0324a70734fb61077853aee9abe67baa9606d1b2 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   createBlock,
   createVNode,
@@ -120,7 +121,7 @@ describe('vnode', () => {
   })
 
   describe('children normalization', () => {
-    const nop = jest.fn
+    const nop = vi.fn
 
     test('null', () => {
       const vnode = createVNode('p', null, null)
index 44ed34373dc3ab07f952003bd984c409291da467..7b9b731807442cc9cccf59d637e71bdbda5e36ae 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   render,
@@ -40,22 +41,22 @@ describe('renderer: vnode hooks', () => {
 
   test('should work on element', () => {
     const hooks: VNodeProps = {
-      onVnodeBeforeMount: jest.fn(),
-      onVnodeMounted: jest.fn(),
-      onVnodeBeforeUpdate: jest.fn(vnode => {
+      onVnodeBeforeMount: vi.fn(),
+      onVnodeMounted: vi.fn(),
+      onVnodeBeforeUpdate: vi.fn(vnode => {
         expect((vnode.el as TestElement).children[0]).toMatchObject({
           type: NodeTypes.TEXT,
           text: 'foo'
         })
       }),
-      onVnodeUpdated: jest.fn(vnode => {
+      onVnodeUpdated: vi.fn(vnode => {
         expect((vnode.el as TestElement).children[0]).toMatchObject({
           type: NodeTypes.TEXT,
           text: 'bar'
         })
       }),
-      onVnodeBeforeUnmount: jest.fn(),
-      onVnodeUnmounted: jest.fn()
+      onVnodeBeforeUnmount: vi.fn(),
+      onVnodeUnmounted: vi.fn()
     }
 
     assertHooks(hooks, h('div', hooks, 'foo'), h('div', hooks, 'bar'))
@@ -65,22 +66,22 @@ describe('renderer: vnode hooks', () => {
     const Comp = (props: { msg: string }) => props.msg
 
     const hooks: VNodeProps = {
-      onVnodeBeforeMount: jest.fn(),
-      onVnodeMounted: jest.fn(),
-      onVnodeBeforeUpdate: jest.fn(vnode => {
+      onVnodeBeforeMount: vi.fn(),
+      onVnodeMounted: vi.fn(),
+      onVnodeBeforeUpdate: vi.fn(vnode => {
         expect(vnode.el as TestElement).toMatchObject({
           type: NodeTypes.TEXT,
           text: 'foo'
         })
       }),
-      onVnodeUpdated: jest.fn(vnode => {
+      onVnodeUpdated: vi.fn(vnode => {
         expect(vnode.el as TestElement).toMatchObject({
           type: NodeTypes.TEXT,
           text: 'bar'
         })
       }),
-      onVnodeBeforeUnmount: jest.fn(),
-      onVnodeUnmounted: jest.fn()
+      onVnodeBeforeUnmount: vi.fn(),
+      onVnodeUnmounted: vi.fn()
     }
 
     assertHooks(
index f7d6d7007c1871574f5fa6ed8da1d6295c7697d9..0cd88846354a5819d4161183c940b50af6179e77 100644 (file)
@@ -2,7 +2,6 @@ import {
   ComponentInternalInstance,
   currentInstance,
   isInSSRComponentSetup,
-  LifecycleHooks,
   setCurrentInstance,
   unsetCurrentInstance
 } from './component'
@@ -11,6 +10,7 @@ import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
 import { warn } from './warning'
 import { toHandlerKey } from '@vue/shared'
 import { DebuggerEvent, pauseTracking, resetTracking } from '@vue/reactivity'
+import { LifecycleHooks } from './enums'
 
 export { onActivated, onDeactivated } from './components/KeepAlive'
 
index 0bc718f1b50521740270afe784271bb3790d2206..b04ae6e51f532f5f5701b7ad6a353660c6a221b8 100644 (file)
@@ -70,6 +70,7 @@ import {
   validateCompatConfig
 } from './compat/compatConfig'
 import { SchedulerJob } from './scheduler'
+import { LifecycleHooks } from './enums'
 
 export type Data = Record<string, unknown>
 
@@ -165,23 +166,6 @@ export { ComponentOptions }
 
 type LifecycleHook<TFn = Function> = TFn[] | null
 
-export const enum LifecycleHooks {
-  BEFORE_CREATE = 'bc',
-  CREATED = 'c',
-  BEFORE_MOUNT = 'bm',
-  MOUNTED = 'm',
-  BEFORE_UPDATE = 'bu',
-  UPDATED = 'u',
-  BEFORE_UNMOUNT = 'bum',
-  UNMOUNTED = 'um',
-  DEACTIVATED = 'da',
-  ACTIVATED = 'a',
-  RENDER_TRIGGERED = 'rtg',
-  RENDER_TRACKED = 'rtc',
-  ERROR_CAPTURED = 'ec',
-  SERVER_PREFETCH = 'sp'
-}
-
 // use `E extends any` to force evaluating type to fix #2362
 export type SetupContext<E = EmitsOptions> = E extends any
   ? {
diff --git a/packages/runtime-core/src/enums.ts b/packages/runtime-core/src/enums.ts
new file mode 100644 (file)
index 0000000..63d829d
--- /dev/null
@@ -0,0 +1,16 @@
+export const enum LifecycleHooks {
+  BEFORE_CREATE = 'bc',
+  CREATED = 'c',
+  BEFORE_MOUNT = 'bm',
+  MOUNTED = 'm',
+  BEFORE_UPDATE = 'bu',
+  UPDATED = 'u',
+  BEFORE_UNMOUNT = 'bum',
+  UNMOUNTED = 'um',
+  DEACTIVATED = 'da',
+  ACTIVATED = 'a',
+  RENDER_TRIGGERED = 'rtg',
+  RENDER_TRACKED = 'rtc',
+  ERROR_CAPTURED = 'ec',
+  SERVER_PREFETCH = 'sp'
+}
index d190b993d435fcab436f4362c20890f134ced728..afbd226c4c6aa53b71a507574be579ec4bfa44c5 100644 (file)
@@ -1,7 +1,8 @@
 import { VNode } from './vnode'
-import { ComponentInternalInstance, LifecycleHooks } from './component'
+import { ComponentInternalInstance } from './component'
 import { warn, pushWarningContext, popWarningContext } from './warning'
 import { isPromise, isFunction } from '@vue/shared'
+import { LifecycleHooks } from './enums'
 
 // contexts where user provided function may be executed, in addition to
 // lifecycle hooks.
@@ -23,7 +24,7 @@ export const enum ErrorCodes {
   SCHEDULER
 }
 
-export const ErrorTypeStrings: Record<number | string, string> = {
+export const ErrorTypeStrings: Record<LifecycleHooks | ErrorCodes, string> = {
   [LifecycleHooks.SERVER_PREFETCH]: 'serverPrefetch hook',
   [LifecycleHooks.BEFORE_CREATE]: 'beforeCreate hook',
   [LifecycleHooks.CREATED]: 'created hook',
index 25ab5c67321126b94dd21ede2d66b2f87f1fcbce..471dcfc7ce0caff544d5ead3c32c43def131999c 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { createApp, h } from '../src'
 
 describe('createApp for dom', () => {
@@ -23,7 +24,7 @@ describe('createApp for dom', () => {
       }
     }
 
-    const handler = jest.fn(msg => {
+    const handler = vi.fn(msg => {
       expect(msg).toMatch(`Component is missing template or render function`)
     })
 
index f4199192278aeb429fad59f01b8f4201eafb9346..0e4cdb0ce58970c28df036d9f87acd95be8c6650 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   defineAsyncComponent,
   defineComponent,
@@ -332,7 +333,7 @@ describe('defineCustomElement', () => {
 
     test('emit on connect', () => {
       const e = new E()
-      const spy = jest.fn()
+      const spy = vi.fn()
       e.addEventListener('created', spy)
       container.appendChild(e)
       expect(spy).toHaveBeenCalled()
@@ -341,7 +342,7 @@ describe('defineCustomElement', () => {
     test('emit on interaction', () => {
       container.innerHTML = `<my-el-emits></my-el-emits>`
       const e = container.childNodes[0] as VueElement
-      const spy = jest.fn()
+      const spy = vi.fn()
       e.addEventListener('my-click', spy)
       e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
       expect(spy).toHaveBeenCalledTimes(1)
@@ -354,9 +355,9 @@ describe('defineCustomElement', () => {
     test('case transform for camelCase event', () => {
       container.innerHTML = `<my-el-emits></my-el-emits>`
       const e = container.childNodes[0] as VueElement
-      const spy1 = jest.fn()
+      const spy1 = vi.fn()
       e.addEventListener('myEvent', spy1)
-      const spy2 = jest.fn()
+      const spy2 = vi.fn()
       // emitting myEvent, but listening for my-event. This happens when
       // using the custom element in a Vue template
       e.addEventListener('my-event', spy2)
@@ -374,7 +375,7 @@ describe('defineCustomElement', () => {
       customElements.define('my-async-el-emits', E)
       container.innerHTML = `<my-async-el-emits></my-async-el-emits>`
       const e = container.childNodes[0] as VueElement
-      const spy = jest.fn()
+      const spy = vi.fn()
       e.addEventListener('my-click', spy)
       // this feels brittle but seems necessary to reach the node in the DOM.
       await customElements.whenDefined('my-async-el-emits')
@@ -394,7 +395,7 @@ describe('defineCustomElement', () => {
       customElements.define('my-async-el-props-emits', E)
       container.innerHTML = `<my-async-el-props-emits id="my_async_el_props_emits"></my-async-el-props-emits>`
       const e = container.childNodes[0] as VueElement
-      const spy = jest.fn()
+      const spy = vi.fn()
       e.addEventListener('my-click', spy)
       await customElements.whenDefined('my-async-el-props-emits')
       e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
@@ -549,7 +550,7 @@ describe('defineCustomElement', () => {
 
   describe('async', () => {
     test('should work', async () => {
-      const loaderSpy = jest.fn()
+      const loaderSpy = vi.fn()
       const E = defineCustomElement(
         defineAsyncComponent(() => {
           loaderSpy()
index 34c1c366c924c6042b7b751758cd1514df2ddb6c..24a152e823376ff881cdd14a6366c02e54f85bc9 100644 (file)
@@ -1,14 +1,15 @@
+import { vi } from 'vitest'
 import { render, h } from '@vue/runtime-dom'
 
 describe('customized built-in elements support', () => {
-  let createElement: jest.SpyInstance
+  let createElement: vi.SpyInstance
   afterEach(() => {
     createElement.mockRestore()
   })
 
   test('should created element with is option', () => {
     const root = document.createElement('div')
-    createElement = jest.spyOn(document, 'createElement')
+    createElement = vi.spyOn(document, 'createElement')
     render(h('button', { is: 'plastic-button' }), root)
     expect(createElement.mock.calls[0]).toMatchObject([
       'button',
index f5a0c6fadcc9d471aa1df656387450864c8c169e..eecbfcea7779485140ed4b957c3fb024f6e42dac 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import {
   h,
   render,
@@ -29,7 +30,7 @@ beforeEach(() => {
 
 describe('vModel', () => {
   it('should work with text input', async () => {
-    const manualListener = jest.fn()
+    const manualListener = vi.fn()
     const component = defineComponent({
       data() {
         return { value: null }
@@ -102,7 +103,7 @@ describe('vModel', () => {
   })
 
   it('should work with multiple listeners', async () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const component = defineComponent({
       data() {
         return { value: null }
@@ -131,8 +132,8 @@ describe('vModel', () => {
   })
 
   it('should work with updated listeners', async () => {
-    const spy1 = jest.fn()
-    const spy2 = jest.fn()
+    const spy1 = vi.fn()
+    const spy2 = vi.fn()
     const toggle = ref(true)
 
     const component = defineComponent({
index 477620f6da63ae8ef6f9a83a4ae5522c11b6218f..5a959a7eb42a848618921f4758f053f9ef8ecb18 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { patchEvent } from '../../src/modules/events'
 import { withModifiers, withKeys } from '@vue/runtime-dom'
 
@@ -21,9 +22,9 @@ describe('runtime-dom: v-on directive', () => {
     const parent = document.createElement('div')
     const child = document.createElement('input')
     parent.appendChild(child)
-    const childNextValue = withModifiers(jest.fn(), ['prevent', 'stop'])
+    const childNextValue = withModifiers(vi.fn(), ['prevent', 'stop'])
     patchEvent(child, 'onClick', null, childNextValue, null)
-    const parentNextValue = jest.fn()
+    const parentNextValue = vi.fn()
     patchEvent(parent, 'onClick', null, parentNextValue, null)
     expect(triggerEvent(child, 'click').defaultPrevented).toBe(true)
     expect(parentNextValue).not.toBeCalled()
@@ -33,7 +34,7 @@ describe('runtime-dom: v-on directive', () => {
     const parent = document.createElement('div')
     const child = document.createElement('input')
     parent.appendChild(child)
-    const fn = jest.fn()
+    const fn = vi.fn()
     const handler = withModifiers(fn, ['self'])
     patchEvent(parent, 'onClick', null, handler, null)
     triggerEvent(child, 'click')
@@ -45,7 +46,7 @@ describe('runtime-dom: v-on directive', () => {
 
     keyNames.forEach(keyName => {
       const el = document.createElement('div')
-      const fn = jest.fn()
+      const fn = vi.fn()
       // <div @keyup[keyName].esc="test"/>
       const nextValue = withKeys(withModifiers(fn, [keyName]), [
         'esc',
@@ -79,7 +80,7 @@ describe('runtime-dom: v-on directive', () => {
   test('it should support "exact" modifier', () => {
     const el = document.createElement('div')
     // Case 1: <div @keyup.exact="test"/>
-    const fn1 = jest.fn()
+    const fn1 = vi.fn()
     const next1 = withModifiers(fn1, ['exact'])
     patchEvent(el, 'onKeyup', null, next1, null)
     triggerEvent(el, 'keyup')
@@ -87,7 +88,7 @@ describe('runtime-dom: v-on directive', () => {
     triggerEvent(el, 'keyup', e => (e.ctrlKey = true))
     expect(fn1.mock.calls.length).toBe(1)
     // Case 2: <div @keyup.ctrl.a.exact="test"/>
-    const fn2 = jest.fn()
+    const fn2 = vi.fn()
     const next2 = withKeys(withModifiers(fn2, ['ctrl', 'exact']), ['a'])
     patchEvent(el, 'onKeyup', null, next2, null)
     triggerEvent(el, 'keyup', e => (e.key = 'a'))
@@ -111,7 +112,7 @@ describe('runtime-dom: v-on directive', () => {
     const buttonCodes = { left: 0, middle: 1, right: 2 }
     buttons.forEach(button => {
       const el = document.createElement('div')
-      const fn = jest.fn()
+      const fn = vi.fn()
       const handler = withModifiers(fn, [button])
       patchEvent(el, 'onMousedown', null, handler, null)
       buttons
@@ -127,7 +128,7 @@ describe('runtime-dom: v-on directive', () => {
 
   it('should handle multiple arguments when using modifiers', () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const handler = withModifiers(fn, ['ctrl'])
     const event = triggerEvent(el, 'click', e => (e.ctrlKey = true))
     handler(event, 'value', true)
index 32466f29a7bc739430aafc6e5226f6076ef26ec5..501f8183f6cb13cbb29e07c1a6494ab3b7d2c2df 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { patchProp } from '../src/patchProp'
 
 const timeout = () => new Promise(r => setTimeout(r))
@@ -5,7 +6,7 @@ const timeout = () => new Promise(r => setTimeout(r))
 describe(`runtime-dom: events patching`, () => {
   it('should assign event handler', async () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     patchProp(el, 'onClick', null, fn)
     el.dispatchEvent(new Event('click'))
     await timeout()
@@ -18,8 +19,8 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should update event handler', async () => {
     const el = document.createElement('div')
-    const prevFn = jest.fn()
-    const nextFn = jest.fn()
+    const prevFn = vi.fn()
+    const nextFn = vi.fn()
     patchProp(el, 'onClick', null, prevFn)
     el.dispatchEvent(new Event('click'))
     patchProp(el, 'onClick', prevFn, nextFn)
@@ -34,8 +35,8 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should support multiple event handlers', async () => {
     const el = document.createElement('div')
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
     patchProp(el, 'onClick', null, [fn1, fn2])
     el.dispatchEvent(new Event('click'))
     await timeout()
@@ -45,7 +46,7 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should unassign event handler', async () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     patchProp(el, 'onClick', null, fn)
     patchProp(el, 'onClick', fn, null)
     el.dispatchEvent(new Event('click'))
@@ -55,7 +56,7 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should support event option modifiers', async () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     patchProp(el, 'onClickOnceCapture', null, fn)
     el.dispatchEvent(new Event('click'))
     await timeout()
@@ -66,7 +67,7 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should unassign event handler with options', async () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     patchProp(el, 'onClickCapture', null, fn)
     el.dispatchEvent(new Event('click'))
     await timeout()
@@ -84,14 +85,14 @@ describe(`runtime-dom: events patching`, () => {
     const el = document.createElement('div')
 
     // string should be set as attribute
-    const fn = ((window as any).__globalSpy = jest.fn())
+    const fn = ((window as any).__globalSpy = vi.fn())
     patchProp(el, 'onclick', null, '__globalSpy(1)')
     el.dispatchEvent(new Event('click'))
     await timeout()
     delete (window as any).__globalSpy
     expect(fn).toHaveBeenCalledWith(1)
 
-    const fn2 = jest.fn()
+    const fn2 = vi.fn()
     patchProp(el, 'onclick', '__globalSpy(1)', fn2)
     const event = new Event('click')
     el.dispatchEvent(event)
@@ -102,10 +103,10 @@ describe(`runtime-dom: events patching`, () => {
 
   it('should support stopImmediatePropagation on multiple listeners', async () => {
     const el = document.createElement('div')
-    const fn1 = jest.fn((e: Event) => {
+    const fn1 = vi.fn((e: Event) => {
       e.stopImmediatePropagation()
     })
-    const fn2 = jest.fn()
+    const fn2 = vi.fn()
     patchProp(el, 'onClick', null, [fn1, fn2])
     el.dispatchEvent(new Event('click'))
     await timeout()
@@ -119,8 +120,8 @@ describe(`runtime-dom: events patching`, () => {
     const el2 = document.createElement('div')
 
     // const event = new Event('click')
-    const prevFn = jest.fn()
-    const nextFn = jest.fn()
+    const prevFn = vi.fn()
+    const nextFn = vi.fn()
 
     patchProp(el1, 'onClick', null, prevFn)
     patchProp(el2, 'onClick', null, prevFn)
@@ -153,8 +154,8 @@ describe(`runtime-dom: events patching`, () => {
     const child = document.createElement('div')
     el.appendChild(child)
     document.body.appendChild(el)
-    const childFn = jest.fn()
-    const parentFn = jest.fn()
+    const childFn = vi.fn()
+    const parentFn = vi.fn()
 
     patchProp(child, 'onClick', null, () => {
       childFn()
@@ -178,8 +179,8 @@ describe(`runtime-dom: events patching`, () => {
     const testElement = document.createElement('test-element', {
       is: 'test-element'
     })
-    const fn1 = jest.fn()
-    const fn2 = jest.fn()
+    const fn1 = vi.fn()
+    const fn2 = vi.fn()
 
     // in webComponents, @foo-bar will patch prop 'onFooBar'
     // and @foobar will patch prop 'onFoobar'
index 10ef9e289b4e8e2b867e3a247adca6b5161d6850..56d2eb5d56c6fc60f0742099efc88f76f3ca4bb4 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { patchProp } from '../src/patchProp'
 import { render, h } from '../src'
 
@@ -95,7 +96,7 @@ describe('runtime-dom: props patching', () => {
   })
 
   test('innerHTML unmount prev children', () => {
-    const fn = jest.fn()
+    const fn = vi.fn()
     const comp = {
       render: () => 'foo',
       unmounted: fn
@@ -111,7 +112,7 @@ describe('runtime-dom: props patching', () => {
 
   // #954
   test('(svg) innerHTML unmount prev children', () => {
-    const fn = jest.fn()
+    const fn = vi.fn()
     const comp = {
       render: () => 'foo',
       unmounted: fn
@@ -126,7 +127,7 @@ describe('runtime-dom: props patching', () => {
   })
 
   test('textContent unmount prev children', () => {
-    const fn = jest.fn()
+    const fn = vi.fn()
     const comp = {
       render: () => 'foo',
       unmounted: fn
index 4199293abefd5e72fb6e5bf743cb7ba2701da34c..7c04cb6514a0424003ab98fc5133c704ab6e7cc4 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { patchProp } from '../src/patchProp'
 
 describe(`runtime-dom: style patching`, () => {
@@ -10,7 +11,7 @@ describe(`runtime-dom: style patching`, () => {
   // #1309
   it('should not patch same string style', () => {
     const el = document.createElement('div')
-    const fn = jest.fn()
+    const fn = vi.fn()
     const value = (el.style.cssText = 'color:red;')
     Object.defineProperty(el.style, 'cssText', {
       get(): any {
index bee393069639e5dc836df19b73954be6cc7fa7bd..e307bdc2ed6c337e216645a71f1bf9d3533a9809 100644 (file)
@@ -2,6 +2,7 @@
  * @jest-environment node
  */
 
+import { vi } from 'vitest'
 import {
   createApp,
   h,
@@ -820,8 +821,8 @@ function testRender(type: string, render: typeof renderToString) {
 
     // #2763
     test('error handling w/ async setup', async () => {
-      const fn = jest.fn()
-      const fn2 = jest.fn()
+      const fn = vi.fn()
+      const fn2 = vi.fn()
 
       const asyncChildren = defineComponent({
         async setup() {
@@ -948,8 +949,8 @@ function testRender(type: string, render: typeof renderToString) {
     })
 
     test('onServerPrefetch are run in parallel', async () => {
-      const first = jest.fn(() => Promise.resolve())
-      const second = jest.fn(() => Promise.resolve())
+      const first = vi.fn(() => Promise.resolve())
+      const second = vi.fn(() => Promise.resolve())
       let checkOther = [false, false]
       let done = [false, false]
       const app = createApp({
index 698893ff24797c9d515e5bba29e091fce4189b43..cbc2e4a5990a2ed657ff385d22f33c8c3617478b 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { createSSRApp, defineComponent, h, computed, reactive } from 'vue'
 import { renderToString } from '../src/renderToString'
 
@@ -20,7 +21,7 @@ test('computed reactivity during SSR', async () => {
     }
   }
 
-  const getterSpy = jest.fn()
+  const getterSpy = vi.fn()
 
   const App = defineComponent(async () => {
     const msg = computed(() => {
index dec810221e8860eed19b3df92056bd139b4665a5..bff752bebc48b06c325cc715f5c9336dfd004265 100644 (file)
@@ -2,6 +2,7 @@
  * @jest-environment node
  */
 
+import { vi } from 'vitest'
 import { createApp, h, Suspense } from 'vue'
 import { renderToString } from '../src/renderToString'
 
@@ -33,7 +34,7 @@ describe('SSR Suspense', () => {
 
   test('reject', async () => {
     const Comp = {
-      errorCaptured: jest.fn(() => false),
+      errorCaptured: vi.fn(() => false),
       render() {
         return h(Suspense, null, {
           default: h(RejectingAsync),
@@ -65,7 +66,7 @@ describe('SSR Suspense', () => {
 
   test('resolving component + rejecting component', async () => {
     const Comp = {
-      errorCaptured: jest.fn(() => false),
+      errorCaptured: vi.fn(() => false),
       render() {
         return h(Suspense, null, {
           default: h('div', [h(ResolvingAsync), h(RejectingAsync)]),
@@ -84,7 +85,7 @@ describe('SSR Suspense', () => {
 
   test('failing suspense in passing suspense', async () => {
     const Comp = {
-      errorCaptured: jest.fn(() => false),
+      errorCaptured: vi.fn(() => false),
       render() {
         return h(Suspense, null, {
           default: h('div', [
@@ -109,7 +110,7 @@ describe('SSR Suspense', () => {
 
   test('passing suspense in failing suspense', async () => {
     const Comp = {
-      errorCaptured: jest.fn(() => false),
+      errorCaptured: vi.fn(() => false),
       render() {
         return h(Suspense, null, {
           default: h('div', [
index 2b13233e3e6b0ad497648be39aab653d6f3f9914..a82e460b59bcb48f66b775cbc04ac9a6bb425912 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import { nextTick } from '@vue/runtime-core'
 import { CompilerDeprecationTypes } from '../../compiler-core/src'
@@ -98,7 +99,7 @@ test('COMPILER_V_BIND_OBJECT_ORDER', () => {
 })
 
 test('COMPILER_V_ON_NATIVE', () => {
-  const spy = jest.fn()
+  const spy = vi.fn()
   const vm = new Vue({
     template: `<child @click="spy" @click.native="spy" />`,
     components: {
index eda08d3026ecc91b7694f30dd00e01db61ab0952..78753b9fa1b12cf07c8cfb2d378803af0d445556 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import { effect, isReactive } from '@vue/reactivity'
 import { h, nextTick } from '@vue/runtime-core'
@@ -145,10 +146,10 @@ describe('GLOBAL_EXTEND', () => {
   })
 
   it('should not merge nested mixins created with Vue.extend', () => {
-    const a = jest.fn()
-    const b = jest.fn()
-    const c = jest.fn()
-    const d = jest.fn()
+    const a = vi.fn()
+    const b = vi.fn()
+    const c = vi.fn()
+    const d = vi.fn()
     const A = Vue.extend({
       created: a
     })
@@ -475,7 +476,7 @@ test('local app-level mixin registration should not affect other local apps', ()
   const app1 = createApp({ render: () => h('div') })
   const app2 = createApp({})
 
-  const mixin = { created: jest.fn() }
+  const mixin = { created: vi.fn() }
   app1.mixin(mixin)
   app2.mixin(mixin)
 
index f2aa27d4ec85294dd55608e586f3bfa36ed68394..2a3adddba389490871c15c390e334405a37273bc 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import {
   DeprecationTypes,
@@ -24,8 +25,8 @@ test('GLOBAL_KEY_CODES', () => {
     bar: [38, 87]
   }
 
-  const onFoo = jest.fn()
-  const onBar = jest.fn()
+  const onFoo = vi.fn()
+  const onBar = vi.fn()
 
   const el = document.createElement('div')
   new Vue({
index b6de7f24bbe65d2795daca5b66a50e7e81aac73b..3516c05319adf120df8606e3e213ecb16ed97e57 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import { Slots } from '../../runtime-core/src/componentSlots'
 import { Text } from '../../runtime-core/src/vnode'
@@ -49,11 +50,11 @@ test('INSTANCE_DESTROY', () => {
 // https://github.com/vuejs/vue/blob/dev/test/unit/features/instance/methods-events.spec.js
 describe('INSTANCE_EVENT_EMITTER', () => {
   let vm: LegacyPublicInstance
-  let spy: jest.Mock
+  let spy: vi.Mock
 
   beforeEach(() => {
     vm = new Vue()
-    spy = jest.fn()
+    spy = vi.fn()
   })
 
   it('$on', () => {
@@ -157,7 +158,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
   })
 
   it('$off event + fn', () => {
-    const spy2 = jest.fn()
+    const spy2 = vi.fn()
     vm.$on('test', spy)
     vm.$on('test', spy2)
     vm.$off('test', spy)
@@ -173,7 +174,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
 
 describe('INSTANCE_EVENT_HOOKS', () => {
   test('instance API', () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     const vm = new Vue({ template: 'foo' })
     vm.$on('hook:mounted', spy)
     vm.$mount()
@@ -187,7 +188,7 @@ describe('INSTANCE_EVENT_HOOKS', () => {
   })
 
   test('via template', () => {
-    const spy = jest.fn()
+    const spy = vi.fn()
     new Vue({
       template: `<child @hook:mounted="spy"/>`,
       methods: { spy },
index a788fccb4a68d078bd2c7fad490136bdb0e03b33..4bb7e384e1939160948fe97e4811420c705caadc 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import { nextTick } from '../../runtime-core/src/scheduler'
 import {
@@ -47,7 +48,7 @@ test('mode as function', () => {
 })
 
 test('WATCH_ARRAY', async () => {
-  const spy = jest.fn()
+  const spy = vi.fn()
   const vm = new Vue({
     data() {
       return {
@@ -114,7 +115,7 @@ test('PROPS_DEFAULT_THIS', () => {
 })
 
 test('V_ON_KEYCODE_MODIFIER', () => {
-  const spy = jest.fn()
+  const spy = vi.fn()
   const vm = new Vue({
     template: `<input @keyup.1="spy">`,
     methods: { spy }
@@ -131,11 +132,11 @@ test('V_ON_KEYCODE_MODIFIER', () => {
 
 test('CUSTOM_DIR', async () => {
   const myDir = {
-    bind: jest.fn(),
-    inserted: jest.fn(),
-    update: jest.fn(),
-    componentUpdated: jest.fn(),
-    unbind: jest.fn()
+    bind: vi.fn(),
+    inserted: vi.fn(),
+    update: vi.fn(),
+    componentUpdated: vi.fn(),
+    unbind: vi.fn()
   } as any
 
   const getCalls = () =>
index 7baac30dc29fb61b98c97077b73047f2760c0772..75b5a440d3c3fb1fd10db27dc304cd829ad2a7af 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import Vue from '@vue/compat'
 import { nextTick } from '../../runtime-core/src/scheduler'
 import {
@@ -84,8 +85,8 @@ test('data deep merge w/ extended constructor', () => {
 })
 
 test('beforeDestroy/destroyed', async () => {
-  const beforeDestroy = jest.fn()
-  const destroyed = jest.fn()
+  const beforeDestroy = vi.fn()
+  const destroyed = vi.fn()
 
   const child = {
     template: `foo`,
@@ -116,8 +117,8 @@ test('beforeDestroy/destroyed', async () => {
 })
 
 test('beforeDestroy/destroyed in Vue.extend components', async () => {
-  const beforeDestroy = jest.fn()
-  const destroyed = jest.fn()
+  const beforeDestroy = vi.fn()
+  const destroyed = vi.fn()
 
   const child = Vue.extend({
     template: `foo`,
index f5d2450aec228a7e0d131adea23e5edbe9a2f032..c2418790be769829f08a61253dbd5decdd33d2c6 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 import path from 'path'
 import { h, createApp, Transition, ref, nextTick } from 'vue'
@@ -264,12 +265,12 @@ describe('e2e: Transition', () => {
     test(
       'transition events without appear',
       async () => {
-        const beforeLeaveSpy = jest.fn()
-        const onLeaveSpy = jest.fn()
-        const afterLeaveSpy = jest.fn()
-        const beforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
+        const beforeLeaveSpy = vi.fn()
+        const onLeaveSpy = vi.fn()
+        const afterLeaveSpy = vi.fn()
+        const beforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -368,12 +369,12 @@ describe('e2e: Transition', () => {
     test(
       'events with arguments',
       async () => {
-        const beforeLeaveSpy = jest.fn()
-        const onLeaveSpy = jest.fn()
-        const afterLeaveSpy = jest.fn()
-        const beforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
+        const beforeLeaveSpy = vi.fn()
+        const onLeaveSpy = vi.fn()
+        const afterLeaveSpy = vi.fn()
+        const beforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -482,7 +483,7 @@ describe('e2e: Transition', () => {
     )
 
     test('onEnterCancelled', async () => {
-      const enterCancelledSpy = jest.fn()
+      const enterCancelledSpy = vi.fn()
 
       await page().exposeFunction('enterCancelledSpy', enterCancelledSpy)
 
@@ -622,15 +623,15 @@ describe('e2e: Transition', () => {
     test(
       'transition events with appear',
       async () => {
-        const onLeaveSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const onAppearSpy = jest.fn()
-        const beforeLeaveSpy = jest.fn()
-        const beforeEnterSpy = jest.fn()
-        const beforeAppearSpy = jest.fn()
-        const afterLeaveSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
-        const afterAppearSpy = jest.fn()
+        const onLeaveSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const onAppearSpy = vi.fn()
+        const beforeLeaveSpy = vi.fn()
+        const beforeEnterSpy = vi.fn()
+        const beforeAppearSpy = vi.fn()
+        const afterLeaveSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
+        const afterAppearSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -770,12 +771,12 @@ describe('e2e: Transition', () => {
     test(
       'css: false',
       async () => {
-        const onBeforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const onAfterEnterSpy = jest.fn()
-        const onBeforeLeaveSpy = jest.fn()
-        const onLeaveSpy = jest.fn()
-        const onAfterLeaveSpy = jest.fn()
+        const onBeforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const onAfterEnterSpy = vi.fn()
+        const onBeforeLeaveSpy = vi.fn()
+        const onLeaveSpy = vi.fn()
+        const onAfterLeaveSpy = vi.fn()
 
         await page().exposeFunction('onBeforeEnterSpy', onBeforeEnterSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -1219,8 +1220,8 @@ describe('e2e: Transition', () => {
     test(
       'async component transition inside Suspense',
       async () => {
-        const onLeaveSpy = jest.fn()
-        const onEnterSpy = jest.fn()
+        const onLeaveSpy = vi.fn()
+        const onEnterSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -1371,8 +1372,8 @@ describe('e2e: Transition', () => {
     test(
       'out-in mode with Suspense',
       async () => {
-        const onLeaveSpy = jest.fn()
-        const onEnterSpy = jest.fn()
+        const onLeaveSpy = vi.fn()
+        const onEnterSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -1561,12 +1562,12 @@ describe('e2e: Transition', () => {
     test(
       'transition events with v-show',
       async () => {
-        const beforeLeaveSpy = jest.fn()
-        const onLeaveSpy = jest.fn()
-        const afterLeaveSpy = jest.fn()
-        const beforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
+        const beforeLeaveSpy = vi.fn()
+        const onLeaveSpy = vi.fn()
+        const afterLeaveSpy = vi.fn()
+        const beforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
 
         await page().exposeFunction('onLeaveSpy', onLeaveSpy)
         await page().exposeFunction('onEnterSpy', onEnterSpy)
@@ -1667,7 +1668,7 @@ describe('e2e: Transition', () => {
     test(
       'onLeaveCancelled (v-show only)',
       async () => {
-        const onLeaveCancelledSpy = jest.fn()
+        const onLeaveCancelledSpy = vi.fn()
 
         await page().exposeFunction('onLeaveCancelledSpy', onLeaveCancelledSpy)
         await page().evaluate(() => {
@@ -1729,9 +1730,9 @@ describe('e2e: Transition', () => {
     test(
       'transition on appear with v-show',
       async () => {
-        const beforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
+        const beforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
 
         await page().exposeFunction('onEnterSpy', onEnterSpy)
         await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
@@ -1835,9 +1836,9 @@ describe('e2e: Transition', () => {
     test(
       'transition events should not call onEnter with v-show false',
       async () => {
-        const beforeEnterSpy = jest.fn()
-        const onEnterSpy = jest.fn()
-        const afterEnterSpy = jest.fn()
+        const beforeEnterSpy = vi.fn()
+        const onEnterSpy = vi.fn()
+        const afterEnterSpy = vi.fn()
 
         await page().exposeFunction('onEnterSpy', onEnterSpy)
         await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
@@ -2199,8 +2200,8 @@ describe('e2e: Transition', () => {
 
   // #3227
   test(`HOC w/ merged hooks`, async () => {
-    const innerSpy = jest.fn()
-    const outerSpy = jest.fn()
+    const innerSpy = vi.fn()
+    const outerSpy = vi.fn()
 
     const MyTransition = {
       render(this: any) {
index 38d742538a2b02fa10dda599cf9bb3cc7595f34d..a78f3912412cdecf0486a5e1f8f4f4d9e997c251 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 import path from 'path'
 import { createApp, ref } from 'vue'
@@ -359,15 +360,15 @@ describe('e2e: TransitionGroup', () => {
   test(
     'events',
     async () => {
-      const onLeaveSpy = jest.fn()
-      const onEnterSpy = jest.fn()
-      const onAppearSpy = jest.fn()
-      const beforeLeaveSpy = jest.fn()
-      const beforeEnterSpy = jest.fn()
-      const beforeAppearSpy = jest.fn()
-      const afterLeaveSpy = jest.fn()
-      const afterEnterSpy = jest.fn()
-      const afterAppearSpy = jest.fn()
+      const onLeaveSpy = vi.fn()
+      const onEnterSpy = vi.fn()
+      const onAppearSpy = vi.fn()
+      const beforeLeaveSpy = vi.fn()
+      const beforeEnterSpy = vi.fn()
+      const beforeAppearSpy = vi.fn()
+      const afterLeaveSpy = vi.fn()
+      const afterEnterSpy = vi.fn()
+      const afterAppearSpy = vi.fn()
 
       await page().exposeFunction('onLeaveSpy', onLeaveSpy)
       await page().exposeFunction('onEnterSpy', onEnterSpy)
index 90e4453bcd78c539e370442bea06d9e6053cba41..b08de351de10de9b39ebd2cc7a7f3b91efb770bd 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { createApp } from '../src'
 
 // https://github.com/vuejs/docs/pull/1890
@@ -18,8 +19,8 @@ test('custom element event casing', () => {
   const container = document.createElement('div')
   document.body.appendChild(container)
 
-  const handler = jest.fn()
-  const handler2 = jest.fn()
+  const handler = vi.fn()
+  const handler2 = vi.fn()
   createApp({
     template: `
     <custom-event-casing
index a51c7fd97a9a08016e08c7a5ad4ee2a9893e7e2b..f11ea0f022c2ae583915ccfc785fc87fbd213749 100644 (file)
@@ -1,3 +1,4 @@
+import { vi } from 'vitest'
 import { EMPTY_ARR } from '@vue/shared'
 import { createApp, ref, nextTick, reactive } from '../src'
 
@@ -21,11 +22,11 @@ describe('compiler + runtime integration', () => {
     const one = {
       name: 'one',
       template: 'one',
-      created: jest.fn(),
-      mounted: jest.fn(),
-      activated: jest.fn(),
-      deactivated: jest.fn(),
-      unmounted: jest.fn()
+      created: vi.fn(),
+      mounted: vi.fn(),
+      activated: vi.fn(),
+      deactivated: vi.fn(),
+      unmounted: vi.fn()
     }
 
     const toggle = ref(true)
@@ -166,7 +167,7 @@ describe('compiler + runtime integration', () => {
   it('should support selector of rootContainer', () => {
     const container = document.createElement('div')
     const origin = document.querySelector
-    document.querySelector = jest.fn().mockReturnValue(container)
+    document.querySelector = vi.fn().mockReturnValue(container)
 
     const App = {
       template: `{{ count }}`,
@@ -203,7 +204,7 @@ describe('compiler + runtime integration', () => {
 
   it('should warn when container is not found', () => {
     const origin = document.querySelector
-    document.querySelector = jest.fn().mockReturnValue(null)
+    document.querySelector = vi.fn().mockReturnValue(null)
     const App = {
       template: `{{ count }}`,
       data() {
@@ -226,7 +227,7 @@ describe('compiler + runtime integration', () => {
     const target = document.createElement('div')
     const count = ref(0)
     const origin = document.querySelector
-    document.querySelector = jest.fn().mockReturnValue(target)
+    document.querySelector = vi.fn().mockReturnValue(target)
 
     const App = {
       template: `
index 20b0032ef038588f22e398e7a73b4f242d14529a..f0f408a61ed735460c7ee1aa6f239494171f6370 100644 (file)
@@ -53,6 +53,7 @@ importers:
       tslib: ^2.4.0
       typescript: ^4.8.0
       vite: ^4.0.4
+      vitest: ^0.28.2
       vue: workspace:*
     devDependencies:
       '@babel/types': 7.16.0
@@ -104,6 +105,7 @@ importers:
       tslib: 2.4.0
       typescript: 4.8.2
       vite: 4.0.4_suj7upvbbzn7525gsozjyvtnxy
+      vitest: 0.28.2_terser@5.15.1
       vue: link:packages/vue
 
   packages/compiler-core:
@@ -1649,6 +1651,16 @@ packages:
       '@babel/types': 7.16.0
     dev: true
 
+  /@types/chai-subset/1.3.3:
+    resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==}
+    dependencies:
+      '@types/chai': 4.3.4
+    dev: true
+
+  /@types/chai/4.3.4:
+    resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==}
+    dev: true
+
   /@types/estree/0.0.48:
     resolution: {integrity: sha512-LfZwXoGUDo0C3me81HXgkBg5CTQYb6xzEl+fNmbO4JdRiSKQ8A0GD1OBBvKAIsbCUgoyAty7m99GqqMQe784ew==}
     dev: true
@@ -1897,6 +1909,38 @@ packages:
       vue: link:packages/vue
     dev: true
 
+  /@vitest/expect/0.28.2:
+    resolution: {integrity: sha512-syEAK7I24/aGR2lXma98WNnvMwAJ+fMx32yPcj8eLdCEWjZI3SH8ozMaKQMy65B/xZCZAl6MXmfjtJb2CpWPMg==}
+    dependencies:
+      '@vitest/spy': 0.28.2
+      '@vitest/utils': 0.28.2
+      chai: 4.3.7
+    dev: true
+
+  /@vitest/runner/0.28.2:
+    resolution: {integrity: sha512-BJ9CtfPwWM8uc5p7Ty0OprwApyh8RIaSK7QeQPhwfDYA59AAE009OytqA3aX0yj1Qy5+k/mYFJS8RJZgsueSGA==}
+    dependencies:
+      '@vitest/utils': 0.28.2
+      p-limit: 4.0.0
+      pathe: 1.1.0
+    dev: true
+
+  /@vitest/spy/0.28.2:
+    resolution: {integrity: sha512-KlLzTzi5E6tHcI12VT+brlY1Pdi7sUzLf9+YXgh80+CfLu9DqPZi38doBBAUhqEnW/emoLCMinPMMoJlNAQZXA==}
+    dependencies:
+      tinyspy: 1.0.2
+    dev: true
+
+  /@vitest/utils/0.28.2:
+    resolution: {integrity: sha512-wcVTNnVdr22IGxZHDgiXrxWYcXsNg0iX2iBuOH3tVs9eme6fXJ0wxjn0/gCpp0TofQSoUwo3tX8LNACFVseDuA==}
+    dependencies:
+      cli-truncate: 3.1.0
+      diff: 5.1.0
+      loupe: 2.3.6
+      picocolors: 1.0.0
+      pretty-format: 27.5.1
+    dev: true
+
   /@vue/consolidate/0.17.3:
     resolution: {integrity: sha512-nl0SWcTMzaaTnJ5G6V8VlMDA1CVVrNnaQKF1aBZU3kXtjgU9jtHMsEAsgjoRUx+T0EVJk9TgbmxGhK3pOk22zw==}
     engines: {node: '>= 0.12.0'}
@@ -2045,6 +2089,11 @@ packages:
     engines: {node: '>=8'}
     dev: true
 
+  /ansi-regex/6.0.1:
+    resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==}
+    engines: {node: '>=12'}
+    dev: true
+
   /ansi-styles/3.2.1:
     resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==}
     engines: {node: '>=4'}
@@ -2064,6 +2113,11 @@ packages:
     engines: {node: '>=10'}
     dev: true
 
+  /ansi-styles/6.2.1:
+    resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
+    engines: {node: '>=12'}
+    dev: true
+
   /anymatch/3.1.2:
     resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
     engines: {node: '>= 8'}
@@ -2117,6 +2171,10 @@ packages:
     resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==}
     dev: true
 
+  /assertion-error/1.1.0:
+    resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
+    dev: true
+
   /astral-regex/2.0.0:
     resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
     engines: {node: '>=8'}
@@ -2402,6 +2460,11 @@ packages:
     engines: {node: '>= 0.8'}
     dev: true
 
+  /cac/6.7.14:
+    resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
+    engines: {node: '>=8'}
+    dev: true
+
   /call-bind/1.0.2:
     resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
     dependencies:
@@ -2442,6 +2505,19 @@ packages:
     resolution: {integrity: sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==}
     dev: true
 
+  /chai/4.3.7:
+    resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==}
+    engines: {node: '>=4'}
+    dependencies:
+      assertion-error: 1.1.0
+      check-error: 1.0.2
+      deep-eql: 4.1.3
+      get-func-name: 2.0.0
+      loupe: 2.3.6
+      pathval: 1.1.1
+      type-detect: 4.0.8
+    dev: true
+
   /chalk/2.4.1:
     resolution: {integrity: sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==}
     engines: {node: '>=4'}
@@ -2479,6 +2555,10 @@ packages:
       is-regex: 1.1.4
     dev: true
 
+  /check-error/1.0.2:
+    resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==}
+    dev: true
+
   /chokidar/3.5.2:
     resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==}
     engines: {node: '>= 8.10.0'}
@@ -2538,6 +2618,14 @@ packages:
       string-width: 4.2.3
     dev: true
 
+  /cli-truncate/3.1.0:
+    resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==}
+    engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+    dependencies:
+      slice-ansi: 5.0.0
+      string-width: 5.1.2
+    dev: true
+
   /clipboardy/2.3.0:
     resolution: {integrity: sha512-mKhiIL2DrQIsuXMgBgnfEHOZOryC7kY7YO//TN6c63wlEm3NG5tz+YgY5rVi29KCmq/QQjKYvM7a19+MDOTHOQ==}
     engines: {node: '>=8'}
@@ -3047,6 +3135,13 @@ packages:
     resolution: {integrity: sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=}
     dev: true
 
+  /deep-eql/4.1.3:
+    resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==}
+    engines: {node: '>=6'}
+    dependencies:
+      type-detect: 4.0.8
+    dev: true
+
   /deep-extend/0.6.0:
     resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
     engines: {node: '>=4.0.0'}
@@ -3100,6 +3195,11 @@ packages:
     engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
     dev: true
 
+  /diff/5.1.0:
+    resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==}
+    engines: {node: '>=0.3.1'}
+    dev: true
+
   /diffie-hellman/5.0.3:
     resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==}
     dependencies:
@@ -3140,6 +3240,10 @@ packages:
       is-obj: 2.0.0
     dev: true
 
+  /eastasianwidth/0.2.0:
+    resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
+    dev: true
+
   /electron-to-chromium/1.4.16:
     resolution: {integrity: sha512-BQb7FgYwnu6haWLU63/CdVW+9xhmHls3RCQUFiV4lvw3wimEHTVcUk2hkuZo76QhR8nnDdfZE7evJIZqijwPdA==}
     dev: true
@@ -3165,6 +3269,10 @@ packages:
     resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
     dev: true
 
+  /emoji-regex/9.2.2:
+    resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
+    dev: true
+
   /emojis-list/3.0.0:
     resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==}
     engines: {node: '>= 4'}
@@ -3765,6 +3873,10 @@ packages:
     engines: {node: 6.* || 8.* || >= 10.*}
     dev: true
 
+  /get-func-name/2.0.0:
+    resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==}
+    dev: true
+
   /get-intrinsic/1.1.1:
     resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==}
     dependencies:
@@ -4244,6 +4356,11 @@ packages:
     engines: {node: '>=8'}
     dev: true
 
+  /is-fullwidth-code-point/4.0.0:
+    resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==}
+    engines: {node: '>=12'}
+    dev: true
+
   /is-generator-fn/2.1.0:
     resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==}
     engines: {node: '>=6'}
@@ -5024,6 +5141,10 @@ packages:
     hasBin: true
     dev: true
 
+  /jsonc-parser/3.2.0:
+    resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
+    dev: true
+
   /jsonfile/4.0.0:
     resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
     optionalDependencies:
@@ -5238,6 +5359,11 @@ packages:
       json5: 1.0.1
     dev: true
 
+  /local-pkg/0.4.3:
+    resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==}
+    engines: {node: '>=14'}
+    dev: true
+
   /locate-path/2.0.0:
     resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==}
     engines: {node: '>=4'}
@@ -5303,6 +5429,12 @@ packages:
       wrap-ansi: 6.2.0
     dev: true
 
+  /loupe/2.3.6:
+    resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==}
+    dependencies:
+      get-func-name: 2.0.0
+    dev: true
+
   /lru-cache/4.1.5:
     resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==}
     dependencies:
@@ -5517,6 +5649,15 @@ packages:
     resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
     dev: true
 
+  /mlly/1.1.0:
+    resolution: {integrity: sha512-cwzBrBfwGC1gYJyfcy8TcZU1f+dbH/T+TuOhtYP2wLv/Fb51/uV7HJQfBPtEupZ2ORLRU1EKFS/QfS3eo9+kBQ==}
+    dependencies:
+      acorn: 8.8.1
+      pathe: 1.1.0
+      pkg-types: 1.0.1
+      ufo: 1.0.1
+    dev: true
+
   /modify-values/1.0.1:
     resolution: {integrity: sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==}
     engines: {node: '>=0.10.0'}
@@ -5749,6 +5890,13 @@ packages:
       yocto-queue: 0.1.0
     dev: true
 
+  /p-limit/4.0.0:
+    resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==}
+    engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+    dependencies:
+      yocto-queue: 1.0.0
+    dev: true
+
   /p-locate/2.0.0:
     resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==}
     engines: {node: '>=4'}
@@ -5874,6 +6022,14 @@ packages:
     engines: {node: '>=8'}
     dev: true
 
+  /pathe/1.1.0:
+    resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==}
+    dev: true
+
+  /pathval/1.1.1:
+    resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
+    dev: true
+
   /pbkdf2/3.1.2:
     resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==}
     engines: {node: '>=0.12'}
@@ -5930,6 +6086,14 @@ packages:
       find-up: 4.1.0
     dev: true
 
+  /pkg-types/1.0.1:
+    resolution: {integrity: sha512-jHv9HB+Ho7dj6ItwppRDDl0iZRYBD0jsakHXtFgoLr+cHSF6xC+QL54sJmWxyGxOLYSHm0afhXhXcQDQqH9z8g==}
+    dependencies:
+      jsonc-parser: 3.2.0
+      mlly: 1.1.0
+      pathe: 1.1.0
+    dev: true
+
   /please-upgrade-node/3.2.0:
     resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==}
     dependencies:
@@ -6038,6 +6202,15 @@ packages:
     hasBin: true
     dev: true
 
+  /pretty-format/27.5.1:
+    resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
+    engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
+    dependencies:
+      ansi-regex: 5.0.1
+      ansi-styles: 5.2.0
+      react-is: 17.0.2
+    dev: true
+
   /pretty-format/29.3.1:
     resolution: {integrity: sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg==}
     engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@@ -6296,6 +6469,10 @@ packages:
       strip-json-comments: 2.0.1
     dev: true
 
+  /react-is/17.0.2:
+    resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
+    dev: true
+
   /react-is/18.2.0:
     resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
     dev: true
@@ -6724,6 +6901,10 @@ packages:
       object-inspect: 1.11.1
     dev: true
 
+  /siginfo/2.0.0:
+    resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
+    dev: true
+
   /signal-exit/3.0.6:
     resolution: {integrity: sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==}
     dev: true
@@ -6765,6 +6946,14 @@ packages:
       is-fullwidth-code-point: 3.0.0
     dev: true
 
+  /slice-ansi/5.0.0:
+    resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==}
+    engines: {node: '>=12'}
+    dependencies:
+      ansi-styles: 6.2.1
+      is-fullwidth-code-point: 4.0.0
+    dev: true
+
   /source-map-js/1.0.1:
     resolution: {integrity: sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==}
     engines: {node: '>=0.10.0'}
@@ -6845,6 +7034,14 @@ packages:
       escape-string-regexp: 2.0.0
     dev: true
 
+  /stackback/0.0.2:
+    resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+    dev: true
+
+  /std-env/3.3.1:
+    resolution: {integrity: sha512-3H20QlwQsSm2OvAxWIYhs+j01MzzqwMwGiiO1NQaJYZgJZFPuAbf95/DiKRBSTYIJ2FeGUc+B/6mPGcWP9dO3Q==}
+    dev: true
+
   /string-argv/0.3.1:
     resolution: {integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==}
     engines: {node: '>=0.6.19'}
@@ -6883,6 +7080,15 @@ packages:
       strip-ansi: 6.0.1
     dev: true
 
+  /string-width/5.1.2:
+    resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}
+    engines: {node: '>=12'}
+    dependencies:
+      eastasianwidth: 0.2.0
+      emoji-regex: 9.2.2
+      strip-ansi: 7.0.1
+    dev: true
+
   /string.prototype.padend/3.1.3:
     resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==}
     engines: {node: '>= 0.4'}
@@ -6944,6 +7150,13 @@ packages:
       ansi-regex: 5.0.1
     dev: true
 
+  /strip-ansi/7.0.1:
+    resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==}
+    engines: {node: '>=12'}
+    dependencies:
+      ansi-regex: 6.0.1
+    dev: true
+
   /strip-bom/3.0.0:
     resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=}
     engines: {node: '>=4'}
@@ -6981,6 +7194,12 @@ packages:
     engines: {node: '>=8'}
     dev: true
 
+  /strip-literal/1.0.0:
+    resolution: {integrity: sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==}
+    dependencies:
+      acorn: 8.8.1
+    dev: true
+
   /supports-color/5.5.0:
     resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
     engines: {node: '>=4'}
@@ -7112,6 +7331,20 @@ packages:
     resolution: {integrity: sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==}
     dev: true
 
+  /tinybench/2.3.1:
+    resolution: {integrity: sha512-hGYWYBMPr7p4g5IarQE7XhlyWveh1EKhy4wUBS1LrHXCKYgvz+4/jCqgmJqZxxldesn05vccrtME2RLLZNW7iA==}
+    dev: true
+
+  /tinypool/0.3.0:
+    resolution: {integrity: sha512-NX5KeqHOBZU6Bc0xj9Vr5Szbb1j8tUHIeD18s41aDJaPeC5QTdEhK0SpdpUrZlj2nv5cctNcSjaKNanXlfcVEQ==}
+    engines: {node: '>=14.0.0'}
+    dev: true
+
+  /tinyspy/1.0.2:
+    resolution: {integrity: sha512-bSGlgwLBYf7PnUsQ6WOc6SJ3pGOcd+d8AA6EUnLDDM0kWEstC1JIlSZA3UNliDXhd9ABoS7hiRBDCu+XP/sf1Q==}
+    engines: {node: '>=14.0.0'}
+    dev: true
+
   /tmpl/1.0.5:
     resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
     dev: true
@@ -7281,6 +7514,10 @@ packages:
     hasBin: true
     dev: true
 
+  /ufo/1.0.1:
+    resolution: {integrity: sha512-boAm74ubXHY7KJQZLlXrtMz52qFvpsbOxDcZOnw/Wf+LS4Mmyu7JxmzD4tDLtUQtmZECypJ0FrCz4QIe6dvKRA==}
+    dev: true
+
   /uglify-js/3.17.4:
     resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==}
     engines: {node: '>=0.8.0'}
@@ -7379,6 +7616,29 @@ packages:
     engines: {node: '>= 0.8'}
     dev: true
 
+  /vite-node/0.28.2_cuughdtwg7b3rwlnomrzdiszke:
+    resolution: {integrity: sha512-zyiJ3DLs9zXign4P2MD4PQk+7rdT+JkHukgmmS0KuImbCQ7WnCdea5imQVeT6OtUsBwsLztJxQODUsinVr91tg==}
+    engines: {node: '>=v14.16.0'}
+    hasBin: true
+    dependencies:
+      cac: 6.7.14
+      debug: 4.3.4
+      mlly: 1.1.0
+      pathe: 1.1.0
+      picocolors: 1.0.0
+      source-map: 0.6.1
+      source-map-support: 0.5.21
+      vite: 4.0.4_cuughdtwg7b3rwlnomrzdiszke
+    transitivePeerDependencies:
+      - '@types/node'
+      - less
+      - sass
+      - stylus
+      - sugarss
+      - supports-color
+      - terser
+    dev: true
+
   /vite/4.0.4:
     resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
     engines: {node: ^14.18.0 || >=16.0.0}
@@ -7412,6 +7672,41 @@ packages:
       fsevents: 2.3.2
     dev: true
 
+  /vite/4.0.4_cuughdtwg7b3rwlnomrzdiszke:
+    resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
+    engines: {node: ^14.18.0 || >=16.0.0}
+    hasBin: true
+    peerDependencies:
+      '@types/node': '>= 14'
+      less: '*'
+      sass: '*'
+      stylus: '*'
+      sugarss: '*'
+      terser: ^5.4.0
+    peerDependenciesMeta:
+      '@types/node':
+        optional: true
+      less:
+        optional: true
+      sass:
+        optional: true
+      stylus:
+        optional: true
+      sugarss:
+        optional: true
+      terser:
+        optional: true
+    dependencies:
+      '@types/node': 16.18.2
+      esbuild: 0.16.17
+      postcss: 8.4.21
+      resolve: 1.22.1
+      rollup: 3.10.0
+      terser: 5.15.1
+    optionalDependencies:
+      fsevents: 2.3.2
+    dev: true
+
   /vite/4.0.4_suj7upvbbzn7525gsozjyvtnxy:
     resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
     engines: {node: ^14.18.0 || >=16.0.0}
@@ -7447,6 +7742,61 @@ packages:
       fsevents: 2.3.2
     dev: true
 
+  /vitest/0.28.2_terser@5.15.1:
+    resolution: {integrity: sha512-HJBlRla4Mng0OiZ8aWunCecJ6BzLDA4yuzuxiBuBU2MXjGB6I4zT7QgIBL/UrwGKlNxLwaDC5P/4OpeuTlW8yQ==}
+    engines: {node: '>=v14.16.0'}
+    hasBin: true
+    peerDependencies:
+      '@edge-runtime/vm': '*'
+      '@vitest/browser': '*'
+      '@vitest/ui': '*'
+      happy-dom: '*'
+      jsdom: '*'
+    peerDependenciesMeta:
+      '@edge-runtime/vm':
+        optional: true
+      '@vitest/browser':
+        optional: true
+      '@vitest/ui':
+        optional: true
+      happy-dom:
+        optional: true
+      jsdom:
+        optional: true
+    dependencies:
+      '@types/chai': 4.3.4
+      '@types/chai-subset': 1.3.3
+      '@types/node': 16.18.2
+      '@vitest/expect': 0.28.2
+      '@vitest/runner': 0.28.2
+      '@vitest/spy': 0.28.2
+      '@vitest/utils': 0.28.2
+      acorn: 8.8.1
+      acorn-walk: 8.2.0
+      cac: 6.7.14
+      chai: 4.3.7
+      debug: 4.3.4
+      local-pkg: 0.4.3
+      pathe: 1.1.0
+      picocolors: 1.0.0
+      source-map: 0.6.1
+      std-env: 3.3.1
+      strip-literal: 1.0.0
+      tinybench: 2.3.1
+      tinypool: 0.3.0
+      tinyspy: 1.0.2
+      vite: 4.0.4_cuughdtwg7b3rwlnomrzdiszke
+      vite-node: 0.28.2_cuughdtwg7b3rwlnomrzdiszke
+      why-is-node-running: 2.2.2
+    transitivePeerDependencies:
+      - less
+      - sass
+      - stylus
+      - sugarss
+      - supports-color
+      - terser
+    dev: true
+
   /vlq/0.2.3:
     resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==}
     dev: true
@@ -7530,6 +7880,15 @@ packages:
       isexe: 2.0.0
     dev: true
 
+  /why-is-node-running/2.2.2:
+    resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==}
+    engines: {node: '>=8'}
+    hasBin: true
+    dependencies:
+      siginfo: 2.0.0
+      stackback: 0.0.2
+    dev: true
+
   /widest-line/2.0.1:
     resolution: {integrity: sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==}
     engines: {node: '>=4'}
@@ -7708,6 +8067,11 @@ packages:
     engines: {node: '>=10'}
     dev: true
 
+  /yocto-queue/1.0.0:
+    resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
+    engines: {node: '>=12.20'}
+    dev: true
+
   /z-schema/5.0.4:
     resolution: {integrity: sha512-gm/lx3hDzJNcLwseIeQVm1UcwhWIKpSB4NqH89pTBtFns4k/HDHudsICtvG05Bvw/Mv3jMyk700y5dadueLHdA==}
     engines: {node: '>=8.0.0'}
diff --git a/scripts/setupVitest.ts b/scripts/setupVitest.ts
new file mode 100644 (file)
index 0000000..81a78d2
--- /dev/null
@@ -0,0 +1,94 @@
+import { vi } from 'vitest'
+
+expect.extend({
+  toHaveBeenWarned(received: string) {
+    asserted.add(received)
+    const passed = warn.mock.calls.some(args => args[0].includes(received))
+    if (passed) {
+      return {
+        pass: true,
+        message: () => `expected "${received}" not to have been warned.`
+      }
+    } else {
+      const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
+      return {
+        pass: false,
+        message: () =>
+          `expected "${received}" to have been warned` +
+          (msgs.length
+            ? `.\n\nActual messages:\n\n - ${msgs}`
+            : ` but no warning was recorded.`)
+      }
+    }
+  },
+
+  toHaveBeenWarnedLast(received: string) {
+    asserted.add(received)
+    const passed =
+      warn.mock.calls[warn.mock.calls.length - 1][0].includes(received)
+    if (passed) {
+      return {
+        pass: true,
+        message: () => `expected "${received}" not to have been warned last.`
+      }
+    } else {
+      const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
+      return {
+        pass: false,
+        message: () =>
+          `expected "${received}" to have been warned last.\n\nActual messages:\n\n - ${msgs}`
+      }
+    }
+  },
+
+  toHaveBeenWarnedTimes(received: string, n: number) {
+    asserted.add(received)
+    let found = 0
+    warn.mock.calls.forEach(args => {
+      if (args[0].includes(received)) {
+        found++
+      }
+    })
+
+    if (found === n) {
+      return {
+        pass: true,
+        message: () => `expected "${received}" to have been warned ${n} times.`
+      }
+    } else {
+      return {
+        pass: false,
+        message: () =>
+          `expected "${received}" to have been warned ${n} times but got ${found}.`
+      }
+    }
+  }
+})
+
+let warn
+const asserted: Set<string> = new Set()
+
+beforeEach(() => {
+  asserted.clear()
+  warn = vi.spyOn(console, 'warn')
+  warn.mockImplementation(() => {})
+})
+
+afterEach(() => {
+  const assertedArray = Array.from(asserted)
+  const nonAssertedWarnings = warn.mock.calls
+    .map(args => args[0])
+    .filter(received => {
+      return !assertedArray.some(assertedMsg => {
+        return received.includes(assertedMsg)
+      })
+    })
+  warn.mockRestore()
+  if (nonAssertedWarnings.length) {
+    throw new Error(
+      `test case threw unexpected warnings:\n - ${nonAssertedWarnings.join(
+        '\n - '
+      )}`
+    )
+  }
+})
diff --git a/vitest.config.ts b/vitest.config.ts
new file mode 100644 (file)
index 0000000..1d573ea
--- /dev/null
@@ -0,0 +1,43 @@
+import { defineConfig } from 'vitest/config'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { readdirSync } from 'node:fs'
+
+const resolve = p =>
+  path.resolve(fileURLToPath(import.meta.url), `../packages/${p}/src`)
+const dirs = readdirSync(new URL('./packages', import.meta.url))
+const alias = {}
+for (const dir of dirs) {
+  alias[`@vue/${dir}`] = resolve(dir)
+}
+
+export default defineConfig({
+  define: {
+    __DEV__: true,
+    __TEST__: true,
+    __VERSION__: '"test"',
+    __BROWSER__: false,
+    __GLOBAL__: false,
+    __ESM_BUNDLER__: true,
+    __ESM_BROWSER__: false,
+    __NODE_JS__: true,
+    __SSR__: true,
+    __FEATURE_OPTIONS_API__: true,
+    __FEATURE_SUSPENSE__: true,
+    __FEATURE_PROD_DEVTOOLS__: false,
+    __COMPAT__: true
+  },
+  resolve: {
+    alias: {
+      ...alias,
+      vue: resolve('vue'),
+      'vue/compiler-sfc': resolve('compiler-sfc'),
+      'vue/server-renderer': resolve('server-renderer'),
+      '@vue/compat': resolve('vue-compat')
+    }
+  },
+  test: {
+    globals: true,
+    setupFiles: 'scripts/setupVitest.ts'
+  }
+})