Skip to content

Correct way to await in vitest #73

Description

@hypeJunction

It is quite unclear how to properly await propagation of query results in query stores during testing.

Your own code uses this quite crazy logic:

export const advance = async (ms = 0) => {
    await new Promise<void>((r) => r());
    await new Promise<void>((r) => r());
    vi.advanceTimersByTime(ms);
    await new Promise<void>((r) => r());
    await new Promise<void>((r) => r());
};

How should this been done in client code? Shold nanostores/query expose a test helper to hide away this complexity?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions