forked from vitejs/vite
/
legacy.spec.ts
56 lines (50 loc) · 1.52 KB
/
legacy.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
import { isBuild, readManifest, untilUpdated } from '../../testUtils'
test('should work', async () => {
expect(await page.textContent('#app')).toMatch('Hello')
})
test('import.meta.env.LEGACY', async () => {
expect(await page.textContent('#env')).toMatch(isBuild ? 'true' : 'false')
})
// https://github.com/vitejs/vite/issues/3400
test('transpiles down iterators correctly', async () => {
expect(await page.textContent('#iterators')).toMatch('hello')
})
test('wraps with iife', async () => {
expect(await page.textContent('#babel-helpers')).toMatch(
'exposed babel helpers: false'
)
})
test('generates assets', async () => {
await untilUpdated(
() => page.textContent('#assets'),
isBuild
? [
'index: 404',
'index-legacy: 404',
'chunk-async: 404',
'chunk-async-legacy: 404',
'immutable-chunk: 200',
'immutable-chunk-legacy: 200',
'polyfills-legacy: 404'
].join('\n')
: [
'index: 404',
'index-legacy: 404',
'chunk-async: 404',
'chunk-async-legacy: 404',
'immutable-chunk: 404',
'immutable-chunk-legacy: 404',
'polyfills-legacy: 404'
].join('\n'),
true
)
})
if (isBuild) {
test('should generate correct manifest', async () => {
const manifest = readManifest()
expect(manifest['../../../vite/legacy-polyfills']).toBeDefined()
expect(manifest['../../../vite/legacy-polyfills'].src).toBe(
'../../../vite/legacy-polyfills'
)
})
}