Replies: 1 comment 2 replies
-
I think the best way to get a form dirty is to use the Here's the example. describe("Submit button", () => {
it("The submit button is disabled, when the form is not dirty", () => {
render(<App />);
expect(screen.getByText("Submit")).toBeDisabled();
});
it("he submit button is enabled, when the form is dirty", async () => {
render(<App />);
await userEvent.type(screen.getByPlaceholderText("First Name"), "Sujin");
expect(screen.getByText("Submit")).toBeEnabled();
});
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a small component that uses
FormContext
to pull some form state off the context and show different things depending on whether the field is dirty (in addition to some other things).In my test I'm creating a wrapper that calls
useForm
and wraps the component with aFormProvider
, but so far I can't find a great way to set the dirty state. Does anyone have any ideas?Beta Was this translation helpful? Give feedback.
All reactions