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

await tick() doesn't work when using in tests but waitFor does #249

Closed
macmillen opened this issue Jul 12, 2023 · 2 comments
Closed

await tick() doesn't work when using in tests but waitFor does #249

macmillen opened this issue Jul 12, 2023 · 2 comments

Comments

@macmillen
Copy link

    const user = userEvent.setup();
    await user.type(inputElement, "{backspace}");
    waitFor(() => expect(screen.getByTestId("super-auto-tag")).toHaveTextContent("Lukasz")); // this works
    const user = userEvent.setup();
    await user.type(inputElement, "{backspace}");
    await tick(); // this doesn't work
    expect(screen.getByTestId("super-auto-tag")).toHaveTextContent("Lukasz");
@sebastianrothe
Copy link
Collaborator

I have to use await tick(); multiple times (like 10x) for some of my tests.

@yanick
Copy link
Collaborator

yanick commented Jan 23, 2024

I kinda expect this is caused by the expected output being dependent on something reacting to a change reacting to a change reacting to the original event, which would indeed takes several tick() to stabilize.

Since tick() is part of svelte itself, I don't think there is much we can do here. Using waitFor seems to be the obvious and reasonable thing to do.

@yanick yanick closed this as completed Jan 23, 2024
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

3 participants