Skip to content

Commit

Permalink
test: test for timer
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 17, 2024
1 parent ab3b64e commit 0bc3590
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,23 @@ describe('nuxt-time', async () => {

it('displays relative time correctly', async () => {
const page = await createPage(undefined, { locale: 'en-GB' })
const logs: string[] = []

page.on('console', (event) => {
if (!event.text().includes('<Suspense>')) {
logs.push(event.text())
}
})

await page.goto(url('/'), { waitUntil: 'networkidle' })

expect(await page.getByTestId('relative').textContent()).toMatchInlineSnapshot(
'"5 minutes ago"',
'"30 seconds ago"',
)

await page.getByTestId('relative').getByText('32 seconds ago').textContent()

// No hydration errors
expect(logs.join('')).toMatchInlineSnapshot('""')
})
})

0 comments on commit 0bc3590

Please sign in to comment.