Use vitest
This commit is contained in:
parent
b46de85926
commit
cca5e31f56
15 changed files with 825 additions and 96 deletions
21
test/fixtures/setup_test.js
vendored
21
test/fixtures/setup_test.js
vendored
|
|
@ -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()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue