Skip to content

Commit

Permalink
test: browser logs are polled
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 19, 2024
1 parent affe3f2 commit 43c4bcc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tap/.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ test('passes tests', async (user) => {
await user.typeText('#js', script, { paste: true }).click('[type=submit]')

await scriptTag()
let i = 0
const interval = setInterval(() => {
t.getBrowserConsoleMessages().then(({ log: messages }) => {
messages.forEach((message, index) => {
if (i && index <= i) return
i++
console.log(message)
})
})
}, 100)

let stats
do {
await new Promise((resolve) => setTimeout(resolve, 1000))
stats = await t.eval(() => globalThis.stats)
} while (!stats)

const { log } = await t.getBrowserConsoleMessages()
for (const entry of log) {
console.log(entry)
}
clearInterval(interval)

await t.expect(stats?.failed).eql(0)
})

0 comments on commit 43c4bcc

Please sign in to comment.