[Vuejs]-Vue/Jasmine: grabbing an element without using a ref

0👍

Template refs are used in Vue application to restrict from uncontrolled direct access to DOM that leads to poor quality code. There’s no such restriction for tests.

Vue Test utils already has everything to access DOM elements:

wrapper.find('div');

It makes sense to have element attributes that allow for unique selectors for testing purposes, conventionally data-testid.

Leave a comment