/
dynamic-import.spec.ts
61 lines (51 loc) · 2.04 KB
/
dynamic-import.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { isBuild, untilUpdated } from '../../testUtils'
test('should load literal dynamic import', async () => {
await page.click('.baz')
await untilUpdated(() => page.textContent('.view'), 'Baz view', true)
})
test('should load full dynamic import from public', async () => {
await page.click('.qux')
await untilUpdated(() => page.textContent('.view'), 'Qux view', true)
// No warning should be logged as we are using @vite-ignore
expect(
serverLogs.some((log) => log.includes('cannot be analyzed by vite'))
).toBe(false)
})
test('should load data URL of `blob:`', async () => {
await page.click('.issue-2658-1')
await untilUpdated(() => page.textContent('.view'), 'blob', true)
})
test('should load data URL of `data:`', async () => {
await page.click('.issue-2658-2')
await untilUpdated(() => page.textContent('.view'), 'data', true)
})
test('should have same reference on static and dynamic js import', async () => {
await page.click('.mxd')
await untilUpdated(() => page.textContent('.view'), 'true', true)
})
// in this case, it is not possible to detect the correct module
test('should have same reference on static and dynamic js import', async () => {
await page.click('.mxd2')
await untilUpdated(() => page.textContent('.view'), 'false', true)
})
test('should have same reference on static and dynamic js import', async () => {
await page.click('.mxdjson')
await untilUpdated(() => page.textContent('.view'), 'true', true)
})
// since this test has a timeout, it should be put last so that it
// does not bleed on the last
test('should load dynamic import with vars', async () => {
await page.click('.foo')
await untilUpdated(() => page.textContent('.view'), 'Foo view', true)
await page.click('.bar')
await untilUpdated(() => page.textContent('.view'), 'Bar view', true)
})
// dynamic import css
test('should load dynamic import with css', async () => {
await page.click('.css')
await untilUpdated(
() => page.$eval('.view', (node) => window.getComputedStyle(node).color),
'rgb(255, 0, 0)',
true
)
})