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

Is simulate() still deprecated? #2530

Closed
mferber opened this issue Jul 13, 2021 · 4 comments
Closed

Is simulate() still deprecated? #2530

mferber opened this issue Jul 13, 2021 · 4 comments
Labels

Comments

@mferber
Copy link

mferber commented Jul 13, 2021

Issue #2173 (June 2019) says simulate() is deprecated, but as of mid-2021 the docs haven't been updated. The issue says "A PR to make this clear in the docs would be welcomed," but the resulting PR (#2182) has been sitting around unmerged for 2 years. Should we still consider the deprecation an official statement, or was that just one developer's opinion?

(Reason for asking: disagreement over whether to use simulate() in new code)

@ljharb
Copy link
Member

ljharb commented Jul 13, 2021

It is one developer’s opinion - mine - but since I’m the only developer on enzyme, it’s also an official statement.

Avoid use of simulate in all code, new or otherwise. It doesn’t faithfully simulate anything.

@mferber
Copy link
Author

mferber commented Jul 13, 2021

Thank you! (I win the argument. :-) )

@arvinsim
Copy link

arvinsim commented Nov 19, 2021

Wait, so if I want to do fire a onChange event, I should not use .simulate('change', { target: { value: "someValue" } })?

If so what is the correct way to do it? .props().onChange()?

@ljharb
Copy link
Member

ljharb commented Nov 19, 2021

@arvinsim yes, precisely, altho you can also do .invoke('onChange')({ target: { value: 'someValue' } }).

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

No branches or pull requests

3 participants