-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
e2e.spec.ts
29 lines (26 loc) · 926 Bytes
/
e2e.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { fileURLToPath } from 'node:url'
import { describe, it, expect } from 'vitest'
import { setup, $fetch, createPage, url } from '@nuxt/test-utils/e2e'
await setup({
server: true,
browser: true,
rootDir: fileURLToPath(new URL('../playground', import.meta.url)),
})
describe('nuxt-workers', () => {
it('should work on the server', async () => {
expect(await $fetch('/')).toContain('Hello from worker!')
})
it('should work on the client', async () => {
const page = await createPage()
const logs: string[] = []
page.on('console', (log) => {
logs.push(log.text())
})
await page.goto(url('/'))
expect(logs).toMatchInlineSnapshot(`[]`)
await page.getByText('Load client side message').click()
expect(logs).toMatchInlineSnapshot(`[]`)
expect(await page.getByText('Client-side message: Hello from worker!').textContent()).toBeDefined()
await page.close()
})
})