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

Need to test value of va-text-input component for unit testing #2020

Closed
1 task
vsaleem opened this issue Aug 21, 2023 · 1 comment
Closed
1 task

Need to test value of va-text-input component for unit testing #2020

vsaleem opened this issue Aug 21, 2023 · 1 comment

Comments

@vsaleem
Copy link

vsaleem commented Aug 21, 2023

Support question

  • I’ve searched for any related issues/questions on github

How can we help?

    Hi there!  I am trying to chai write unit tests that checks the input text change of the va-text-input component while using the React Testing Library.  I am using a data-testid on the va-text-input component to pinpoint it's value, however when I use fireEvent.change from the React Testing Library, I receive this error: "Error: The given element does not have a value setter."  This indicates that the va-text-input is not a 'true' input type component. 

Can you help me find a way to test this component so that I can alter the text value? Any method would work, I'm currently shot of ideas.

Thanks!

What you have tried:

  1. Tried using fireEvent.change and fireEvent.input with the component's data-testid attribute to change the value of the input field within a chai unit test.

What problem does this solve?

  This problem prevents in-depth testing on the va-text-input component.. If this issue can be resolved developers will be able to just the text value presented inside the input field.

Additional Context

@micahchiang
Copy link
Contributor

Hi @vsaleem - React Testing Library doesn't support shadow dom usage, this is a known issue

You can find an example of testing inputs in the shadow dom with cypress here. I recommend using cypress here if you can.

@caw310 caw310 closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants