I'm currently having problems writing tests for formik fields that use value. I've managed to get my tests to work if instead of value I use defaultValue but I need to use value. I have tried to console.log in the onChange and know that text is flowing through it but I don't understand why it isn't setting. What do I need to change so that it works?
Example of code I'm trying to test
<TextField
id="name"
label="Profile Name"
onChange={formik.handleChange}
value={formik.values.name}
required
</TextField>
Example of code that the test works on
<TextField
id="name"
label="Profile Name"
onChange={formik.handleChange}
defaultValue={formik.values.name}
required
</TextField>
The currently failing test
test("fills out profile name", () => {
const field = screen.getByLabelText("Profile Name");
userEvent.type(field, "profile name");
expect(field).toHaveValue("profile name");
});
The screen.debug that is telling me the text isn't being set.
<input
aria-invalid="false"
aria-labelledby="TextFieldLabel24"
class="ms-TextField-field field-80"
id="name"
required=""
type="text"
value=""
/>

