simonihmig / ember-native-dom-helpers-codemod

Codemod to transform your jQuery based ember tests to use ember-native-dom-helpers
MIT License
27 stars 9 forks source link

Doesn't account for selectors as variables within `containsJQuerySelectorExtension` #27

Closed scalvert closed 6 years ago

scalvert commented 6 years ago

Currently, if a jQuery selector is represented via a variable:

const SOME_SELECTOR = '.my-class:first';

$(SOME_SELECTOR).click();

the codemod will optimistically transform this to:

const SOME_SELECTOR = '.my-class:first';

await click(SOME_SELECTOR);

This will result in a Syntax Error when running the tests, as querySelector can't handle the custom pseudo selectors sizzle supports.

A conservative approach would be to noop if encountering a selector in a variable.

simonihmig commented 6 years ago

Thanks for reporting! It might be possible to check the value of the variable, so to only opt out of transforming this when the value contains a non-standard selector. Will have to give this a try...

scalvert commented 6 years ago

This is exactly what I was thinking too. LMK if you want help.