-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
preload.spec.ts
32 lines (31 loc) · 998 Bytes
/
preload.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
30
31
32
import { isBuild } from '../../testUtils'
import { port } from './serve'
const url = `http://localhost:${port}`
if (isBuild) {
test('preload on', async () => {
await page.goto(url)
let appHtml = await page.content()
expect(appHtml).not.toMatch(
/link rel="modulepreload".*?href="\/assets\/About\.\w{8}\.js"/
)
// after click button, we will run `__vitePreload` method and insert a modulepreload.
await page.click('button')
appHtml = await page.content()
expect(appHtml).toMatch(
/link rel="modulepreload".*?href="\/assets\/About\.\w{8}\.js"/
)
})
} else {
test('preload off', async () => {
await page.goto(url)
let appHtml = await page.content()
expect(appHtml).not.toMatch(
/link rel="modulepreload".*?href="\/assets\/About\.\w{8}\.js"/
)
await page.click('button')
appHtml = await page.content()
expect(appHtml).not.toMatch(
/link rel="modulepreload".*?href="\/assets\/About\.\w{8}\.js"/
)
})
}