vue-cli-plugin-test-attrs icon indicating copy to clipboard operation
vue-cli-plugin-test-attrs copied to clipboard

Match all the attributes beginning with `data-test-*`

Open WilliamDASILVA opened this issue 7 years ago • 1 comments
trafficstars

Good morning sir,

Wouldn't it be better to match all the dataset attributes beginning with data-test instead of only matching data-test. Per example, in the same page I may have data-test-title and data-test-button. Both are different elements that I want to test separately, instead of setting it's value in the attribute because I find this shorter and faster to type.

Example:

<div>
  <button data-test-button>My button</button>
  <h1 data-test-title>My title</h1>
</div>

In general, I target those elements by using querySelector('[data-test-button]')

What are your opinions about this? Perhaps support both notations? Thank you.

WilliamDASILVA avatar Nov 14 '18 09:11 WilliamDASILVA

Hm, interesting idea. I'm a bit hesitant since a glob would require to actually loop over all the attributes on each ast element to check wether it matches the glob, and i'm worried that could add up in terms of build time over a bigger project.

So if we add it, it should be optional.

LinusBorg avatar Nov 18 '18 12:11 LinusBorg