mainmatter/ember-test-selectors

data-test selectors for components without assigning values

matthias-k opened this issue · 8 comments

Hi,

I tried using data-test-selectors in a component as

{{my-component data-test-my-component}}

however, this breaks the template. Maybe this is a limitation of handlebars, then this would not be fixable, but then it might be helpful to have a comment in the README. If this is actually possible, it would be very convenient, since right now I have to use something like

{{my-component data-test-my-component="1"}}

which looks not as clean.

That is indeed a limitation of Handlebars but one that is supposed to be overcome by https://github.com/simplabs/ember-test-selectors/blob/master/transform-test-selector-params-to-hash-pairs.js. Which versions of Ember and Ember CLI are you on?

a pretty outdated version: Ember 2.9.0, Ember CLI 2.9.1. I guess this is one more reason to finally upgrade to the latest version again and try to stick to the release cycle ;).

It should work correctly though. Can you try cleaning your repo?

What exactly do you mean by "cleaning my repo"?

git clean -dfx && npm install && bower install

This didn't help. I'm now even using ember-cli 2.15.0 and ember-test-selectors 0.3.7 and the error persists:

Parse error on line 2:
...e data-test-selected}}  <label data-tes
-----------------------^
Expecting 'EQUALS', got 'CLOSE'

Maybe this is a limitation of handlebars

yes, the limitation is that if you use data-test-my-component without any value if needs to be written before any attributes that do have a value. we have a comment about this in the README now (see https://github.com/simplabs/ember-test-selectors#usage-in-components)

Great, thanks for your help!