Use vitest

This commit is contained in:
tusooa 2025-02-27 22:54:23 -05:00
commit cca5e31f56
No known key found for this signature in database
GPG key ID: 42AEC43D48433C51
15 changed files with 825 additions and 96 deletions

View file

@ -109,23 +109,18 @@ export const waitForEvent = (wrapper, event, {
timesEmitted = 1
} = {}) => {
const tick = 10
const totalTries = timeout / tick
return new Promise((resolve, reject) => {
let currentTries = 0
const wait = () => {
return vi.waitFor(
() => {
const e = wrapper.emitted(event)
if (e && e.length >= timesEmitted) {
resolve()
return
}
if (currentTries >= totalTries) {
reject(new Error('Event did not fire'))
return
}
++currentTries
setTimeout(wait, tick)
throw new Error('event is not emitted')
},
{
timeout,
interval: tick
}
wait()
})
)
}