/
ssr-deps.spec.ts
123 lines (105 loc) · 3.26 KB
/
ssr-deps.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { expect, test } from 'vitest'
import { port } from './serve'
import { getColor, page } from '~utils'
const url = `http://localhost:${port}`
/**
* test for #5809
*
* NOTE: This test will always succeed now, unless the temporary workaround for Jest can be removed
* See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
*/
test('msg should be encrypted', async () => {
await page.goto(url)
expect(await page.textContent('.encrypted-msg')).not.toMatch(
'Secret Message!',
)
})
test('msg read by fs/promises', async () => {
await page.goto(url)
expect(await page.textContent('.file-message')).toMatch('File Content!')
})
test('msg from primitive export', async () => {
await page.goto(url)
expect(await page.textContent('.primitive-export-message')).toMatch(
'Hello World!',
)
})
test('msg from TS transpiled exports', async () => {
await page.goto(url)
expect(await page.textContent('.ts-default-export-message')).toMatch(
'Hello World!',
)
expect(await page.textContent('.ts-named-export-message')).toMatch(
'Hello World!',
)
})
test('msg from Object.assign exports', async () => {
await page.goto(url)
expect(await page.textContent('.object-assigned-exports-message')).toMatch(
'Hello World!',
)
})
test('msg from forwarded exports', async () => {
await page.goto(url)
expect(await page.textContent('.forwarded-export-message')).toMatch(
'Hello World!',
)
})
test('msg from define properties exports', async () => {
await page.goto(url)
expect(await page.textContent('.define-properties-exports-msg')).toMatch(
'Hello World!',
)
})
test('msg from define property exports', async () => {
await page.goto(url)
expect(await page.textContent('.define-property-exports-msg')).toMatch(
'Hello World!',
)
})
test('msg from only object assigned exports', async () => {
await page.goto(url)
expect(await page.textContent('.only-object-assigned-exports-msg')).toMatch(
'Hello World!',
)
})
test('msg from no external cjs', async () => {
await page.goto(url)
expect(await page.textContent('.no-external-cjs-msg')).toMatch('Hello World!')
})
test('msg from optimized with nested external', async () => {
await page.goto(url)
expect(await page.textContent('.optimized-with-nested-external')).toMatch(
'Hello World!',
)
})
test('msg from optimized cjs with nested external', async () => {
await page.goto(url)
expect(await page.textContent('.optimized-cjs-with-nested-external')).toMatch(
'Hello World!',
)
})
test('msg from external using external entry', async () => {
await page.goto(url)
expect(await page.textContent('.external-using-external-entry')).toMatch(
'Hello World!',
)
})
test('msg from linked no external', async () => {
await page.goto(url)
expect(await page.textContent('.linked-no-external')).toMatch(
`Hello World from ${process.env.NODE_ENV}!`,
)
})
test('msg from linked no external', async () => {
await page.goto(url)
expect(await page.textContent('.dep-virtual')).toMatch('[success]')
})
test('import css library', async () => {
await page.goto(url)
expect(await getColor('.css-lib')).toBe('blue')
})
test('import css library', async () => {
await page.goto(url)
expect(await page.textContent('.module-condition')).toMatch('[success]')
})