Closed
Description
As was outlined in this issue, you sometimes need to wait for the next microtask to run before changes in the DOM have been flushed.
const input = getByTestId('my-input');
fireEvent.input(input, {target: {value: 'some text'}});
// Wait for the next microtask for `value` to be
// written to a potential bound variable
await tick();
// Check the value of the variable somehow
Maybe we could create a small abstraction over fireEvent
from dom-testing-library
and return a tick
promise so that fireEvent
can be awaited directly?
const input = getByTestId('my-input');
await fireEvent.input(input, {target: {value: 'some text'}});
// Check the value of the variable somehow
import {
getQueriesForElement,
prettyDOM,
fireEvent as dtlFireEvent
} from '@testing-library/dom'
import { tick } from 'svelte'
export * from '@testing-library/dom'
export function fireEvent(...args) {
dtlFireEvent(...args)
return tick()
}
Metadata
Metadata
Assignees
Labels
No labels