Skip to content

Question: How to use a real Transition component? #1913

Answered by cexbrayat
hasan-almujtaba asked this question in Q&A
Discussion options

You must be logged in to vote

Ha OK. It's not a problem with the watcher then. It's because your test uses a transition mock (this is the case by default in VTU), and that mock won't emit events like afterEnter. You can try to use:

global: {  
  stubs: {
    transition: false
  }
}

to use the real transition component, but then you'll have to trigger the next frame for the animation to finish. If I remember correctly, you can mock requestAnimationFrame to do so with something like:

vi.spyOn(window, 'requestAnimationFrame').mockImplementation(cb => cb())

So something like this works:

  it('should set width based on props', async () => {
    vi.spyOn(window, 'requestAnimationFrame').mockImplementation(cb => cb());
    c…

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cexbrayat
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hasan-almujtaba
Comment options

Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #1912 on December 15, 2022 09:08.