testing-library/testing-library-docs

HTML5 validation errors - can't find anything in documentation.

dwjohnston opened this issue · 2 comments

Describe the bug

I'm trying to make assertions on the existence of HTML5 Validation errors

These things:
image

I have searched 'html5' across the github issues here and for testing-library, as well as on the testing library site - and I can't find any mention of whether this is supported or not.

This StackOverflow question suggests that this is not possible, as well as others facing the same problem (1 2 )

Expected behavior

Looking for a canonical answer whether testing for this behaviour is supported by testing library, and suggestions on otherwise best practises.

A second part of this, is the behaviour of form submission. A real browser will not fire the submit handler if the HTML5 validation is not adherred to, but RTL/jsdom will.

This is a bit of a pain for testing, because some of my tests just want to be 'If you haven't filled out the form, then the callback will not be fired'.

Repro for this here: https://github.com/dwjohnston/rtl-html5-validation

I'm not raising this issue as a feature request - but I think this should be clear in the documentation.

Hi @dwjohnston, thanks for opening this one.
This all comes down to whether the test environment you're using supports these features or not. At the moment, jsdom doesnt.
Since this isn't related to testing-library directly, I don't think that writing something about it in the docs will help (it can confuse others not using jsdom for example).
Since this issue is out of our scope, I'm closing it for now. Feel free to comment here again or re-open if you think otherwise.
Thanks again!