testing-library / testing-library/user-event

Submitting a form by clicking on submit button throws jsdom console errors for unimplemented submit

Open
#1,297 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs assessment
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Reproduction example

https://github.com/ItamarGronich/react-testing-library-submit-form

Prerequisites
  1. Clone the repo
  2. Install dependencies with pnpm i
  3. run test with pnpm test
Expected behavior

Submitting a form by simply clicking the submit button should not log any errors to the console.

Actual behavior

Submitting a form by clicking the submit button logs jsdom errors for unimplemented submit

Error: Not implemented: HTMLFormElement.prototype.requestSubmit
User-event version

14.6.1

Environment

Testing Library framework: @testing-library/react@16.3.0
JS framework: react@19.1.1
Test environment: jest@30.0.5
DOM implementation: jsdom@26.1.0

Additional context

First of all i want to express my deep appreciation of testing library, how it's orchestrated and written.
It's truly a fine piece of open source software and a delight to use so Kudos to everyone involved 🎉 🐙

I know this is an un-implemented feature in jsdom.

I was actually shocked and couldn't believe that it was, because well....

The internet was made so people can submit forms...

But it's true: https://github.com/jsdom/jsdom/issues/1937

And i understand why, Domenic said it was a massive undertaking.

So this is technically not @testing-library/user-event's fault.

What can we do to make this experience better?
Can you think of a way that testing library can help here?

I thought maybe we can implemented some workaround in the code like creating a userEvent.submit utility which handles this special case without triggering jsdom unimplemented submit , or maybe explain the problem and how to submit forms with a click on the submit button without error logs?

Because right now, my ci logs are spammed with ungodly amount of these error logs, and i want to keep my CI logs clean, lean and inspectable while also taking care not to mute and nuke important error logs coming from my tools.

I know that it doesn't actually fail anything because it's not a real error but just a console error, but I dove quite deep in the rabbit hole to try and find some workarounds.

Some workarounds involved:

  1. mocking the virtual console in the test - i don't like this. i don't want to ask my users to workaround such a trivial case of submitting a form the solution has to be at the infrastructure level.
  2. creating a wrapper jsdom environment and muting the jsdom submit errors. This might be the solution but it feels also a bit shaky since i'm muting an error which actually tells me something is un-implemented. if someone where to use submit anywhere it won't work and no error would appear.
  3. fire submit event directly on the form - this is wrong imho because it goes against the testing-library philosophy of testing like a real user and the whole reason user-events was created in the first place. users don't go submitting forms programmatically, the click on the submit button.

I feel like jest+jsdom+user_events should be a very common pattern. Possbily the most common pattern.
And submitting forms, is surely the most common action to do on the web.
And right now, this very popular and modern combo has an error log when you submit a form the right way.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository: install its dependencies with pnpm i and run pnpm test to reproduce the jsdom HTMLFormElement.prototype.requestSubmit console error. Trace the click-to-submit behavior in user-event and determine whether the expected result—no spurious console errors while preserving genuine errors—can be achieved without requiring users to suppress jsdom output.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.