Setting widgets values with enzyme test framework

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

05 May 2020, 10:07


in order to test a react App with enzyme, the app can be "mounted".

Code: Select all

var app_wrapper = mount(<App />);
Then we can get "pointers" on components (by specifying the component class and a correct selector)

For a Button:

Code: Select all

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

Code: Select all

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

Code: Select all

var slider= app_wrapper.find('Slider[<selector>]');
Then setting values or clicking buttons can be simulated:

Code: Select all

button .simulate("click");  // OK
input.simulate('change', { target: { value: "__TEXT__" } }); // OK.

But it seems, it doesn't work for a slider (not for a Dropdown) widget.

Code: Select all

slider.simulate('change', { target: { value: "55" } }); // does not work
slider.simulate('change', { value: "55" } ); // does not work

I didn't try other widgets.

Any tipps ?

Thanks in advance.

PS: Maybe I posted this twice. Sorry.

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 2 guests