Skip to content

export user-event for svelte #250

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

Closed
macmillen opened this issue Jul 12, 2023 · 1 comment
Closed

export user-event for svelte #250

macmillen opened this issue Jul 12, 2023 · 1 comment

Comments

@macmillen
Copy link

Like fireEvent it would be useful if the functions from the @testing-library/user-event package would also call await tick underneath the hood to make the tests run reliably and to avoid calling await tick manually.

Propsed solution:
Export a modified version of user-event inside the @testing-library/svelte package like so:

import { userEvent } from "@testing-library/svelte";
@yanick
Copy link
Collaborator

yanick commented Jan 23, 2024

Not to be a killjoy, but I think I'll close this one for now. I don't want to add a dependency to @testing-library/user-event that a fair percentage of users won't need, and make assumptions on how people use tick() versus waitFor() (mostly considering the latter one is probably safer).

This being said, if anybody want to tag that await tick() at the end of function calls, that should be doable via (:warning: untested):

const user = userEvent.setup();

Object.keys(user).forEach( method => {
   const orig = user[method];
   user[method] = async (...args) => { const result = orig(...args); await tick(); return result }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants