question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example of How to Simulate User Interaction With Formik

See original GitHub issue

One might (in Javascript tests, Selenium tests, bookmarklets, etc.) want to “manually” fill in a Formik input’s value. But, simply setting someInput.value = 5 (obviously) won’t work, as it doesn’t trigger Formik’s logic (and thus the old value reverts back). I tried creating a change event and dispatching it on the affected input, but that wasn’t enough either.

It would be really great if the documentation included a quick recipe for how to “simulate” (ie. create and dispatch) the event or events necessary to make Formik treat a manual change as if it had come from a user.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vinyolivercommented, Apr 16, 2019

@machineghost which library are you using now?

0reactions
nilamsavani91commented, Jan 14, 2020

Can anyone provide me an example of how to test mapPropsToValues?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formik - Testing Library
Example based in this Async Submission Formik example. // myForm.js ... import userEvent from '@testing-library/user-event'
Read more >
Dynamic forms with Formik and React JS. - DEV Community ‍ ‍
Technologies to be used. Creating the project. First steps. Designing the form. Implementing Formik in our form.
Read more >
Tutorial - Formik
Before we start. Welcome to the Formik tutorial. This will teach you everything you need to know to build simple and complex forms...
Read more >
Creating and Validating React Native Forms with Formik
Let's start by creating a simple form button component which is a touchable element that allows the user to interact with the device's...
Read more >
How To Validate a Login Form With React and Formik
In this tutorial, you will create a React project, add the Formik package, customize the Formik component with an onSubmit callback and a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found