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
Nobody has claimed this yet.
- 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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