Skip to content
Advertisement

How to test if component counts array length properly with Jest

I have a component that I am giving an array with objects as props to it like this:

JavaScript

How can I test that the provided array has the correct length, for example if there are two objects in the array, the component should return two, if there is one, one, if there are none then it should return 0, how can I achieve that? I tried

JavaScript

But that does not work

Advertisement

Answer

I guess you want to check if the correct number of childs of some type was rendered (in Vue).

JavaScript

https://lmiller1990.github.io/vue-testing-handbook/finding-elements-and-components.html#findall

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement