Have a hair-pulling component test #2115
Replies: 2 comments
-
Okay, I guess what I didn't realize is that components do not auto-unmount from the DOM in tests? And so, somehow, the component was maintaining state... which... meant that tests fail? Is this a bug? |
Beta Was this translation helpful? Give feedback.
-
Hi @matthew-dean, Your repro is working for me, when I replace |
Beta Was this translation helpful? Give feedback.
-
I have a component that will not update its state in the Vue test with Vitest / Vue Test utils no matter what I do. I've logged everything to make sure the data FOR the template is in the correct state.
No matter what, the mounted component will not update a child component when its state has changed. It updates fine in the actual DOM, but Vue Test Utils will not update it. I tried to reduce it to a simple test case and could not. It worked in the simple case on Stack Blitz.
I even used the
@vueuse
library to use promise timeouts, and used Vue Test UtilsflushPromises
(plusnextTick()
) to make sure enough time has been granted for the template. No matter what I try, Vue Test Utils (or JSDom?? or Vue??) will never ever ever update the component in the HTML.I've spent about 8 hours trying to get Vue to work like Vue, or Vue Test Utils to work like Vue Test Utils, and this one child component will never update. Never. It has all the correct data. All the correct state. But the Vue Test insists that the template cannot and will not change, even though the computed property itself that triggers the change IS IN THE CORRECT STATE.
I'm wondering if anyone can help me?
Beta Was this translation helpful? Give feedback.
All reactions