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

Allow multiple selectors #16

Closed
anichols-ht opened this issue Jan 19, 2023 · 4 comments
Closed

Allow multiple selectors #16

anichols-ht opened this issue Jan 19, 2023 · 4 comments

Comments

@anichols-ht
Copy link

How open would you be to the testAttribute config property being an array (string or array I guess)? Normally you want to enforce consistency, but here's my reasoning. You can't destructure 'data-test-id' in props because it's not a valid variable name, so I'd love to be able to do this:

// in consumer
<SomeComponentWithAButton dataTest="something" />

// in component
const SomeComponentWithAButton = ({ dataTest }) => {
  <button data-test={`btn-${ dataTest }`}>blah</button>
};

Currently that doesn't work. I'd have to use data-test everywhere, and then in the actual component do something like

({ other, props, ...rest }) => {
  const dataTest = rest['data-test']
}

Either that or an option to turn the rule off for all components and only enforce it on html elements. But I prefer the former cause I do want to enforce dataTest being there.

@davidcalhoun
Copy link
Owner

davidcalhoun commented Jan 24, 2023

Thanks for the input, that use case makes sense to me. I could see how it would be useful to have testAttribute either as a string (as it's implemented now, e.g. 'data-test') or optionally as an array (as you're suggesting, ['data-test', 'dataTest']). If you'd like to submit a PR I'll take a look.

@KhaledMohamedP
Copy link
Contributor

@davidcalhoun @anichols-ht Created this PR #19 , let me know how we can get it to the finish line :)

@KhaledMohamedP
Copy link
Contributor

@davidcalhoun can you publish a new version of the package and close this ticket?

@davidcalhoun
Copy link
Owner

Sorry for the delay, I wanted to make sure there was good test coverage. I've now added it and published a new release - multiple test selectors are now supported as of v2.1.0! Thanks folks!

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

No branches or pull requests

3 participants