toBeValid and toBeInvalid could support checks against a <form/> element. <form /> also responds to checkValidity().
Add 'form' to this list:
https://github.com/testing-library/jest-dom/blob/09f7f041805b2a4bcf5ac5c1e8201ee10a69ab9b/src/to-be-invalid.js#L4
expect(form.checkValidity()).toBe(false)
expect(form.checkValidity()).toBe(true)
The current output does not need to be changed:
expect(element).toBeValid()
Received element is not currently valid:
<form />
The current documentation does not need to be changed:
| This allows you to check if the value of a form element is currently valid.
| An element is valid if it is not having an aria-invalid attribute or having false as a value and returning true when calling checkValidity().
The documentation could be amended to include an example that checks a <form/>.
@jsphstls you're right. Are you up to make a PR? I may take this if you prefer. Let me know.
Thanks @gnapse, I can work on it next week if that's alright. Should be quick.
Opened a pull request ^
@gnapse @jsphstls I believe this issue can be closed
Most helpful comment
Thanks @gnapse, I can work on it next week if that's alright. Should be quick.