[READ-ONLY] Mirror of https://github.com/danielroe/nuxt-workers. SSR-safe, zero-config Web Workers integration for Nuxt.
1.0 kB
31 lines
1import { fileURLToPath } from 'node:url'
2import { describe, it, expect } from 'vitest'
3import { setup, $fetch, createPage, url } from '@nuxt/test-utils/e2e'
4
5await setup({
6 server: true,
7 browser: true,
8 rootDir: fileURLToPath(new URL('../playground', import.meta.url)),
9})
10
11describe('nuxt-workers', () => {
12 it('should work on the server', async () => {
13 const html = await $fetch('/')
14 expect(html).toContain('Hello from worker!')
15 expect(html).toContain('Hello from layer worker!')
16 })
17
18 it('should work on the client', async () => {
19 const page = await createPage()
20 const logs: string[] = []
21 page.on('console', (log) => {
22 logs.push(log.text())
23 })
24 await page.goto(url('/'))
25 expect(logs).toMatchInlineSnapshot(`[]`)
26 await page.getByText('Load client side message').click()
27 expect(logs).toMatchInlineSnapshot(`[]`)
28 expect(await page.getByText('Client-side message: Hello from worker!').textContent()).toBeDefined()
29 await page.close()
30 })
31})