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

Change html attribute data-test to data-testId for better testability #987

Closed
Darent98 opened this issue Sep 12, 2024 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@Darent98
Copy link

Is your feature request related to a problem? Please describe.
I am using storybook in my application to create component tests. I also created tests for this component I am using to ensure basic functionality after updates. After updating this package my test failed, because I was querying the label text of the hour picker. Which was 'Open hours overlay ' and now is depending on the selected hour e.g. '08-Open hours overlay'. By analyzing the element i figured out a data-test attribute was already set, but I could not query for it. Storybook is using the Testing Library, which provides methods to query by the data-testId.

Describe the solution you'd like
I think it would be useful to change the data-test attribute to data-testId. Since I don't find anything only about the data-test attribute, but many articles and a large library using data-testId.

Describe alternatives you've considered
Probably you could also just add the data-testId attribute, while also keeping the data-test attribute

Additional context
You can also let me know whats the use case for the data-test attribute that you implemented.

@Darent98 Darent98 added awaiting triage The issue is not reviewed by the maintainers enhancement New feature or request labels Sep 12, 2024
@Jasenkoo
Copy link
Contributor

Jasenkoo commented Oct 9, 2024

You might want to check the following:

import { configure } from '@testing-library/dom';

configure({
  testIdAttribute: 'data-test',
});

I can change it to data-test-id to better match the attribute.

@Jasenkoo Jasenkoo removed the awaiting triage The issue is not reviewed by the maintainers label Oct 9, 2024
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

No branches or pull requests

2 participants