Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify "Firing Events" page #490

Closed
afontcu opened this issue Jun 2, 2020 · 14 comments
Closed

Unify "Firing Events" page #490

afontcu opened this issue Jun 2, 2020 · 14 comments
Labels
organization 📂 Something needs to be moved

Comments

@afontcu
Copy link
Member

afontcu commented Jun 2, 2020

Same thing as #485.

Event firing utilities are mostly "universal", so they could live above DTL docs.

@afontcu afontcu created this issue from a note in Let's rethink docs! (To do) Jun 2, 2020
@MatanBobi
Copy link
Member

I'm up for this one :)

@MatanBobi
Copy link
Member

MatanBobi commented Jun 12, 2020

Hi @afontcu, @kentcdodds.
I saw Kent's tweet a few days ago about "how to know which event to fire".

Do you think a reference to this app or maybe even gathering up this to an example page is worth doing within this task?

Also, do you think we should build a "General"/"Universal" section? Or do you think it's related to "Getting Started"?

@afontcu

This comment has been minimized.

@MatanBobi

This comment has been minimized.

@kentcdodds
Copy link
Member

kentcdodds commented Jun 13, 2020

I think we're ready to start getting PRs ready to document user event as an official export to @testing-library/dom (importable via import {userEvent} from '@testing-library/dom')

Most of the docs from the original repo can be copied, but there are some improvements I think we should make:

  1. No test-ids
  2. If we can help it, less contrived examples. We can use imaginary components (similar to the "Tooltip" component I'm using in the hover example)

Off the top of my head, here are some of the differences (though someone should probably do an accuracy check with the PR testing-library/dom-testing-library#616):

  1. toggleSelectOptions has been removed in favor of deselectOptions/selectOptions
  2. type will now automatically close modifiers (unless skipAutoClose is specified)
  3. type no longer supports allAtOnce (people should use paste which is coming soon)
  4. blur and focus are new supported events
  5. EVERYTHING is now async (user's can't synchronously fire one event after the other, so neither should our tests)
  6. type now supports {del} (delete forwards) and {selectall} (and incidentally, clear is basically a shortcut for this)

I'm sure there are things I'm missing, but if someone could get this started, that would be phenomenal!

@nickmccurdy

This comment has been minimized.

@afontcu
Copy link
Member Author

afontcu commented Jun 13, 2020

Thanks, Kent! That's great news.

If we can help it, less contrived examples. We can use imaginary components (similar to the "Tooltip" component I'm using in the hover example)

Totally agree. If possible, all code examples in docs should be based on "real" components, instead of foo, bar and so on. Bonus points if we unveil concepts and feature by using and growing the same component. It'd mean less cognitive overhead for readers.

  • EVERYTHING is now async (user's can't synchronously fire one event after the other, so neither should our tests)

I gotta say this makes me extremely happy – one less difference to worry about between React Testing Lib and Vue Testing Lib ❤️


I wonder if docs should still mention fireEvent for advanced use cases (at the end of the page or something). I'd say userEvent will not cover each case on day 1, so mentioning that fireEvent is there might make sense.

@kentcdodds
Copy link
Member

@nickmccurdy, only bug fixes will go into user-event for the next little while. No new features or even improvements to "correctness".

@afontcu, I agree. fireEvent should definitely still be documented for advanced use cases and edge cases. But we should consider user event as the default eventing mechanism.

@nickmccurdy

This comment has been minimized.

@kentcdodds

This comment has been minimized.

@nickmccurdy

This comment has been minimized.

@afontcu
Copy link
Member Author

afontcu commented Jun 16, 2020

Ok, so it looks like user-event is not getting merged (yet, hopefully!) into DTL, so we're back to the original plan 😇 testing-library/dom-testing-library#616

@MatanBobi
Copy link
Member

Hopefully it will get merged, but for now it looks like @jacobparis have done some work on this in his PR #502, let's just try to keep them aligned with all the other "universal" work we're doing in #489 and #485

@MatanBobi
Copy link
Member

@alexkrolick I think we can close this one also after #735 was merged, wdyt?

Let's rethink docs! automation moved this from To do to Done Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
organization 📂 Something needs to be moved
Projects
Development

No branches or pull requests

5 participants