Setting Widgets values with enzyme test framework

UI Components for React
Post Reply
Posts: 2
Joined: 05 May 2020, 09:33

05 May 2020, 09:51


for testing a react App with enzyme, the top App can be "mounted"

Code: Select all

var app_wrapper = mount(<App/>)
Then it is possible to get "pointers" on components (with the correct selectors of course):

For a Button:

Code: Select all

var button = app_wrapper.find('Button[<selector>]');
For an InputText:

Code: Select all

var input = app_wrapper.find('InputText[<selector>]');
For a Slider:

Code: Select all

var slider = app_wrapper.find('Slider[<selector>]');
Clicking a Button or setting the value of an InputText "works":

Code: Select all

button.simulate("click");  //OK
input.simulate('change', { target: { value: "__NEW_TEXT__" } }); // OK.
but it seems to be impossible to set the value of a slider (or of a Dropdown) widget. I didn't try others widgets.

Code: Select all

slider.simulate('change', { target: { value: 55 } }); // does not work
slider.simulate('change',  { value: 55 }); // does not work
It is possible at all ?

Thanks for tips.

PS: the Slider widget seems to be no <input type="range"></input> at all. I am missing something?

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests