0

I am using Quasar 2 Vue 3 and @quasar/testing-e2e-jest v3.0.0-alpha.10. I have multiple q-checkbox in my vue component template which I decorated with data-test attribute. How do I find the specific checkbox with wither id, name, and/or data-test? wrapper.find('input[type="checkbox"]); works just find.

Kok How Teh
  • 3,298
  • 6
  • 47
  • 85

1 Answers1

0
wrapper.find('input[id="..."]')

wrapper.find('input[value="..."]')

wrapper.find('input[data-test="..."]')

basically you can search with whatever attribute you want. type is just another HTML attribute for input

Panos Vakalopoulos
  • 515
  • 1
  • 8
  • 23
  • For some reason find doesn't work with 'input[data-test="..."]'. Says that wrapper is empty. – Alexandr Shmidt Sep 11 '22 at 14:13
  • can you console.log the template and check whether that element HAS that attribute in the first place? you can use `console.log(wrapper.html())` for that – Panos Vakalopoulos Sep 13 '22 at 08:18
  • Panos, it was the matter of defining props inside of test description. I mean, that in my case data-test was a props with a dynamic value. So I first had to define it in test. – Alexandr Shmidt Sep 14 '22 at 17:12