-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Expand file tree
/
Copy pathssr-webworker.spec.ts
More file actions
36 lines (30 loc) · 1.07 KB
/
ssr-webworker.spec.ts
File metadata and controls
36 lines (30 loc) · 1.07 KB
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
30
31
32
33
34
35
36
import { expect, test } from 'vitest'
import { port } from './serve'
import { findAssetFile, isBuild, page } from '~utils'
const url = `http://localhost:${port}`
test('/', async () => {
await page.goto(url + '/')
expect(await page.textContent('h1')).toMatch('hello from webworker')
expect(await page.textContent('.linked')).toMatch('dep from upper directory')
expect(await page.textContent('.external')).toMatch('object')
})
test('supports resolve.conditions', async () => {
await page.goto(url)
expect(await page.textContent('.worker-exports')).toMatch('[success] worker')
})
test('respects browser export', async () => {
await page.goto(url)
expect(await page.textContent('.browser-exports')).toMatch(
'[success] browser',
)
})
test('supports nodejs_compat', async () => {
await page.goto(url)
expect(await page.textContent('.nodejs-compat')).toMatch(
'[success] nodejs compat',
)
})
test.runIf(isBuild)('inlineDynamicImports', () => {
const dynamicJsContent = findAssetFile(/dynamic-[-\w]+\.js/, 'worker')
expect(dynamicJsContent).toBeUndefined()
})