1
- import { browserLogs , fetchFromPage , getText , isBuild , testDir } from '~utils' ;
1
+ import { browserLogs , getText , isBuild , testDir } from '~utils' ;
2
2
import { createServer , ViteDevServer } from 'vite' ;
3
3
import { VERSION } from 'svelte/compiler' ;
4
4
@@ -22,114 +22,6 @@ describe('raw', () => {
22
22
const result = await getText ( '#raw' ) ;
23
23
await expect ( result ) . toMatchFileSnapshot ( snapshotFilename ( 'raw' ) ) ;
24
24
} ) ;
25
-
26
- test ( 'Dummy.svelte?raw&svelte&type=preprocessed' , async ( ) => {
27
- const result = await getText ( '#preprocessed' ) ;
28
- await expect ( result ) . toMatchFileSnapshot ( snapshotFilename ( 'preprocessed' ) ) ;
29
- } ) ;
30
-
31
- test ( 'Dummy.svelte?raw&svelte&type=script' , async ( ) => {
32
- const result = await getText ( '#script' ) ;
33
- expect ( result ) . toContain ( 'export default function Dummy' ) ;
34
- } ) ;
35
-
36
- test ( 'Dummy.svelte?raw&svelte&type=script&compilerOptions={"customElement":true}' , async ( ) => {
37
- const result = await getText ( '#wcScript' ) ;
38
- expect ( result ) . toContain ( '$.create_custom_element(Dummy,' ) ;
39
- } ) ;
40
-
41
- test ( 'Dummy.svelte?raw&svelte&type=style' , async ( ) => {
42
- const result = await getText ( '#style' ) ;
43
- await expect ( result ) . toMatchFileSnapshot ( snapshotFilename ( 'style' ) ) ;
44
- } ) ;
45
-
46
- test ( 'Dummy.svelte?raw&svelte&type=all&sourcemap' , async ( ) => {
47
- const result = JSON . parse ( await getText ( '#all' ) ) ;
48
- expect ( result . ast ) . toBeDefined ( ) ;
49
- expect ( result . js ) . toBeDefined ( ) ;
50
- expect ( result . js . code ) . toBeDefined ( ) ;
51
- expect ( result . js . map ) . toBeDefined ( ) ;
52
- expect ( result . css ) . toBeDefined ( ) ;
53
- expect ( result . css . code ) . toBeDefined ( ) ;
54
- expect ( result . css . map ) . toBeDefined ( ) ;
55
- expect ( result . preprocessed ) . toBeDefined ( ) ;
56
- expect ( result . preprocessed . code ) . toBeDefined ( ) ;
57
- expect ( result . preprocessed . map ) . toBeDefined ( ) ;
58
- } ) ;
59
-
60
- describe . runIf ( ! isBuild ) ( 'mixed exports' , ( ) => {
61
- test ( 'Dummy.svelte?raw&svelte&type=preprocessed' , async ( ) => {
62
- const module = await fetchFromPage ( 'src/Dummy.svelte?raw&svelte&type=preprocessed' ) . then (
63
- ( res ) => res . text ( )
64
- ) ;
65
- expect ( module ) . toContain ( 'export const code="<script lang=\\"ts\\">' ) ;
66
- expect ( module ) . toContain ( 'export const map={' ) ;
67
- expect ( module ) . toContain ( 'export const dependencies=[]' ) ;
68
- expect ( module ) . toContain ( 'export default code' ) ;
69
- } ) ;
70
- test ( 'Dummy.svelte?raw&svelte&type=style' , async ( ) => {
71
- const module = await fetchFromPage ( 'src/Dummy.svelte?raw&svelte&type=style' ) . then ( ( res ) =>
72
- res . text ( )
73
- ) ;
74
- expect ( module ) . toContain ( 'export const code="button.' ) ;
75
- expect ( module ) . toContain ( 'export const hasGlobal=false' ) ;
76
- expect ( module ) . toContain ( 'export const map={' ) ;
77
- expect ( module ) . toContain ( 'export default code' ) ;
78
- } ) ;
79
- test ( 'Dummy.svelte?raw&svelte&type=script' , async ( ) => {
80
- const module = await fetchFromPage ( 'src/Dummy.svelte?raw&svelte&type=script' ) . then ( ( res ) =>
81
- res . text ( )
82
- ) ;
83
- expect ( module ) . toContain ( 'export const code="import' ) ;
84
- expect ( module ) . toContain ( 'export const map={' ) ;
85
- expect ( module ) . toContain ( 'export default code' ) ;
86
- } ) ;
87
- test ( 'Dummy.svelte?raw&svelte&type=all' , async ( ) => {
88
- const module = await fetchFromPage ( 'src/Dummy.svelte?raw&svelte&type=all' ) . then ( ( res ) =>
89
- res . text ( )
90
- ) ;
91
- expect ( module ) . toContain ( 'export const ast={"html":' ) ;
92
- expect ( module ) . toContain ( 'export const css={"code":"button' ) ;
93
- expect ( module ) . toContain ( 'export const dependencies=[]' ) ;
94
- expect ( module ) . toContain ( 'export const js={"code":"import ' ) ;
95
- expect ( module ) . toContain ( 'export const lang="ts"' ) ;
96
- expect ( module ) . toContain ( 'export const metadata={"runes":false}' ) ;
97
- expect ( module ) . toContain ( 'export const normalizedFilename="/src/Dummy.svelte"' ) ;
98
- expect ( module ) . toContain ( 'export const preprocessed={"code":"<script lang=\\"ts\\">' ) ;
99
- expect ( module ) . toContain ( 'export const source="<script lang=\\"ts\\">' ) ;
100
- expect ( module ) . toContain ( 'export const ssr=false' ) ;
101
- expect ( module ) . toContain ( 'export const warnings=[]' ) ;
102
- } ) ;
103
- } ) ;
104
- } ) ;
105
-
106
- describe . runIf ( ! isBuild ) ( 'direct' , ( ) => {
107
- test ( 'Dummy.svelte?direct&svelte&type=style&sourcemap&lang.css' , async ( ) => {
108
- const response = await fetchFromPage (
109
- 'src/Dummy.svelte?direct&svelte&type=style&sourcemap&lang.css' ,
110
- {
111
- headers : { Accept : 'text/css' }
112
- }
113
- ) ;
114
- expect ( response . ok ) . toBe ( true ) ;
115
- expect ( response . headers . get ( 'Content-Type' ) ) . toBe ( 'text/css' ) ;
116
- const css = await response . text ( ) ;
117
- expect ( css ) . toContain ( 'button.' ) ;
118
- expect ( css ) . toContain ( '/*# sourceMappingURL=data' ) ;
119
- } ) ;
120
- test ( 'Dummy.svelte?direct&svelte&type=script&sourcemap&lang.js' , async ( ) => {
121
- const response = await fetchFromPage (
122
- 'src/Dummy.svelte?direct&svelte&type=script&sourcemap&lang.js' ,
123
- {
124
- headers : { Accept : 'text/javascript' }
125
- }
126
- ) ;
127
- expect ( response . ok ) . toBe ( true ) ;
128
- expect ( response . headers . get ( 'Content-Type' ) ) . toMatch ( / ^ (?: t e x t | a p p l i c a t i o n ) \/ j a v a s c r i p t $ / ) ;
129
- const js = await response . text ( ) ;
130
- expect ( js ) . toContain ( 'export default function Dummy' ) ;
131
- expect ( js ) . toContain ( '//# sourceMappingURL=data' ) ;
132
- } ) ;
133
25
} ) ;
134
26
135
27
describe . runIf ( ! isBuild ) ( 'ssrLoadModule' , ( ) => {
@@ -158,29 +50,4 @@ describe.runIf(!isBuild)('ssrLoadModule', () => {
158
50
const result = await ssrLoadDummy ( '?raw' ) ;
159
51
await expect ( result ) . toMatchFileSnapshot ( snapshotFilename ( 'ssr-raw' ) ) ;
160
52
} ) ;
161
- test ( '?raw&svelte&type=preprocessed' , async ( ) => {
162
- const result = await ssrLoadDummy ( '?raw&svelte&type=preprocessed' ) ;
163
- await expect ( result ) . toMatchFileSnapshot ( snapshotFilename ( 'ssr-preprocessed' ) ) ;
164
- } ) ;
165
- test ( '?raw&svelte&type=script' , async ( ) => {
166
- const result = await ssrLoadDummy ( '?raw&svelte&type=script' ) ;
167
- expect ( result ) . toContain ( 'export default function Dummy' ) ;
168
- } ) ;
169
- test ( '?raw&svelte&type=script&compilerOptions={"customElement":true}' , async ( ) => {
170
- const result = await ssrLoadDummy (
171
- '?raw&svelte&type=script&compilerOptions={"customElement":true}'
172
- ) ;
173
- expect ( result ) . toContain ( '$.create_custom_element(Dummy,' ) ;
174
- } ) ;
175
- test ( '?raw&svelte&type=style' , async ( ) => {
176
- const result = await ssrLoadDummy ( '?raw&svelte&type=style' ) ;
177
- expect ( result ) . toContain ( 'button.' ) ;
178
- } ) ;
179
- test ( '?inline&svelte&type=style&lang.css' , async ( ) => {
180
- // Preload Dummy.svelte first so its CSS is processed in the module graph, otherwise loading
181
- // its css inlined url directly will return the raw svelte file rather than the style
182
- await ssrLoadDummy ( '' ) ;
183
- const result = await ssrLoadDummy ( '?inline&svelte&type=style&lang.css' ) ;
184
- expect ( result ) . toContain ( 'button.' ) ;
185
- } ) ;
186
53
} ) ;
0 commit comments