vitest-dev / vitest-dev/vitest

Allow users to override the default options of `@testing-library/user-event` used under the hood by Locator in preview mode

Open
#9,882 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement: pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 21h
Merged PRs (30d)
92

Description

Clear and concise description of the problem

When using preview mode — mostly in webcontainer environments such as Stackblitz — methods such as Locator#fill never resolve when fake timers are in manual mode.

It would be nice if users could override the advanceTime option of userEvent.setup() that is used under the hood to either use real timers or advance fake timer.

Suggested solution

Allow users to configure default user-event options with some API such as:

import { userEvent }  from 'vitest/browser';
userEvent.setDefaultOptions({ advanceTime });

Another approach — which is probably better — is to make the PreviewLocator use a userEvent instance where the time is advanced with real timers.
This would make it more symmetric to other providers.

Alternative

No response

Additional context

No response

Validations

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 packages/browser-preview/src/locators.ts, especially PreviewLocator and the userEvent.setup() instance used by Locator methods. Reproduce the manual fake-timer case in preview mode, then determine whether configurable user-event defaults or real-timer advancement is the intended direction; done means Locator#fill and related methods resolve in that environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.