From c47aee2ee3af08bf815dd3c872265817b57f5c6a Mon Sep 17 00:00:00 2001 From: haoziqaq <357229046@qq.com> Date: Tue, 18 May 2021 10:42:21 +0800 Subject: [PATCH] test(ui/jest): add mockStubs method to resolve transition stub out issue affects: @varlet/ui --- packages/varlet-ui/src/utils/jest.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/varlet-ui/src/utils/jest.ts b/packages/varlet-ui/src/utils/jest.ts index 9d625303994..e8e6716ae2e 100644 --- a/packages/varlet-ui/src/utils/jest.ts +++ b/packages/varlet-ui/src/utils/jest.ts @@ -1,5 +1,5 @@ import { ComponentPublicInstance, nextTick } from 'vue' -import { VueWrapper, DOMWrapper } from '@vue/test-utils' +import { VueWrapper, DOMWrapper, config } from '@vue/test-utils' export const delay = (time: number) => new Promise((resolve) => setTimeout(resolve, time)) @@ -194,3 +194,15 @@ export function mockFileReader(url: string) { }, } } + +export function mockStubs() { + const originStubs = config.global.stubs + + config.global.stubs = {} + + return { + mockRestore() { + config.global.stubs = originStubs + }, + } +}