Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for data-test-* properties #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jrjohnson
Copy link
Contributor

When these are set to boolean true they are added to the element,
boolean false are skipped (can't think of why these would exist)
When they are set to a literal value that value is used.

Anything else throws.

I only handled classic components because I'm not sure if setting properties like this works on classes. If that's a working case let me know and I'll add it.

Fixes #34

When these are set to boolean true they are added to the element,
boolean false are skipped (can't think of why these would exist)
When they are set to a literal value that value is used.

Anything else throws.
Copy link
Contributor

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrjohnson thanks for the PR. similar to the ember-component-css code we have, could you add a check that only enables this transform if the app has a ember-test-selectors dependency? 🙏

@Turbo87 Turbo87 added the enhancement New feature or request label Mar 30, 2020
@jrjohnson
Copy link
Contributor Author

@Turbo87 ✔️

@@ -125,6 +127,9 @@ module.exports = function transformClassicComponent(root, options) {
let classNameBindings = findClassNameBindings(properties);
debug('classNameBindings: %o', classNameBindings);

let dataTestAttributes = findDataTestAttributes(properties);
debug('dataTestAttributes: %o', dataTestAttributes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, instead of creating a dedicated thing here, I'm wondering if it would be easier to just add all the data-test-* properties to the attribute bindings? that's what ember-test-selectors does internally and it would also support computed properties that way. I'm just not sure if data-test-foo={{this.data-test-foo}} is valid code due to the - in the property name 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for data-test-* properties on the JS class
2 participants