Skip to content

how to test method in vue file #2226

Closed Answered by cexbrayat
xxholly32 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @xxholly32

You have to spy on the function before clicking on the button with vi.spyOn(wrapper.vm, 'handleClick')
Also you probably need to have parenthesis on your function call in your template @click="handleClick()"

If that does not work, can you provide us a small repro online using https://stackblitz.com/github/vuejs/create-vue-templates/tree/main/typescript-vitest?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts ?

It only takes a few minutes, and we'll be able to take a look

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@xxholly32
Comment options

@cexbrayat
Comment options

Answer selected by cexbrayat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants