Skip to content

Commit

Permalink
test(ui/jest): add mockStubs method to resolve transition stub out issue
Browse files Browse the repository at this point in the history
affects: @varlet/ui
  • Loading branch information
haoziqaq committed May 18, 2021
1 parent 4f4e290 commit c47aee2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/varlet-ui/src/utils/jest.ts
Original file line number Diff line number Diff line change
@@ -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))

Expand Down Expand Up @@ -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
},
}
}

0 comments on commit c47aee2

Please sign in to comment.