@ph-fritsche - Would it be possible to add an advance option to type?
The typeImpl function could then call that with the delay before await ing on the promise.
As an example of the approach, I'm using this "wrapper" around type (it only works for plaintext):
async function typeWithDelay(input, text, delayInMilliseconds) {
let previous = Promise.resolve();
for (const codepoint of text) {
await previous;
userEvent.type(input, codepoint);
previous = new Promise((resolve) => setTimeout(() => resolve(), delayInMilliseconds));
act(() => {
jest.advanceTimersByTime(delayInMilliseconds);
});
}
}
So instead of above, I could just call userEvent.type(input, 'some text', { delay: 20, advance: jest.advanceTimersByTime });
Originally posted by @icedtoast in #565 (comment)
@ph-fritsche - Would it be possible to add an
advanceoption to type?The typeImpl function could then call that with the delay before
awaiting on the promise.As an example of the approach, I'm using this "wrapper" around type (it only works for plaintext):
So instead of above, I could just call
userEvent.type(input, 'some text', { delay: 20, advance: jest.advanceTimersByTime });Originally posted by @icedtoast in #565 (comment)