How to mock Vaadin components with Jest/Vitest in a Vue project

133 Views Asked by At

I'm currently working in a Vue+javascript project that uses Vaadin components. I'm trying to test our code using vitest + vue testing library, but I'm having problems mocking the third party components.

I found a way using stubs https://test-utils.vuejs.org/guide/advanced/stubs-shallow-mount.html, but the solution does not fit properly, because to use them I need the components to be Vue and they are not. So I have to wrap all vaadin components individually in a <template> and then mock them with the stub. Too much work for a huge project.

I'd rather find a way mocking them using __mocks__ file, but that does not work. Well, what happens is that I'm not able to connect the tests with the mocks file, they just don't see eachother.
This is how I set it up (but I've tried many names): enter image description here

This is the location of the combobox inside node-modules: enter image description here

Any ideas of how can I do it?

0

There are 0 best solutions below