@@ -12,7 +12,6 @@ import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setu
12
12
describeBuilder ( buildApplication , APPLICATION_BUILDER_INFO , ( harness ) => {
13
13
describe ( 'Option: "index"' , ( ) => {
14
14
beforeEach ( async ( ) => {
15
- // Application code is not needed for index tests
16
15
await harness . writeFile ( 'src/main.ts' , 'console.log("TEST");' ) ;
17
16
} ) ;
18
17
@@ -140,92 +139,72 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
140
139
} ) ;
141
140
} ) ;
142
141
143
- it ( 'should generate initial preload link elements when preloadInitial is true' , async ( ) => {
144
- harness . useTarget ( 'build' , {
145
- ...BASE_OPTIONS ,
146
- index : {
147
- input : 'src/index.html' ,
148
- preloadInitial : true ,
149
- } ,
150
- } ) ;
151
-
152
- // Setup an initial chunk usage for JS
153
- await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
154
- await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
155
- await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
142
+ describe ( 'preload' , ( ) => {
143
+ it ( 'should generate initial preload link elements when preloadInitial is true' , async ( ) => {
144
+ harness . useTarget ( 'build' , {
145
+ ...BASE_OPTIONS ,
146
+ index : {
147
+ input : 'src/index.html' ,
148
+ preloadInitial : true ,
149
+ } ,
150
+ } ) ;
156
151
157
- const { result } = await harness . executeOnce ( ) ;
152
+ // Setup an initial chunk usage for JS
153
+ await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
154
+ await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
155
+ await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
158
156
159
- expect ( result ?. success ) . toBe ( true ) ;
160
- harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
161
- harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'modulepreload' ) ;
162
- harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'chunk-' ) ;
163
- } ) ;
157
+ const { result } = await harness . executeOnce ( ) ;
164
158
165
- it ( 'should generate initial preload link elements when preloadInitial is undefined' , async ( ) => {
166
- harness . useTarget ( 'build' , {
167
- ...BASE_OPTIONS ,
168
- index : {
169
- input : 'src/index.html' ,
170
- preloadInitial : undefined ,
171
- } ,
159
+ expect ( result ?. success ) . toBe ( true ) ;
160
+ harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
161
+ harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'modulepreload' ) ;
162
+ harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'chunk-' ) ;
172
163
} ) ;
173
164
174
- // Setup an initial chunk usage for JS
175
- await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
176
- await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
177
- await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
165
+ it ( 'should generate initial preload link elements when preloadInitial is undefined' , async ( ) => {
166
+ harness . useTarget ( 'build' , {
167
+ ...BASE_OPTIONS ,
168
+ index : {
169
+ input : 'src/index.html' ,
170
+ preloadInitial : undefined ,
171
+ } ,
172
+ } ) ;
178
173
179
- const { result } = await harness . executeOnce ( ) ;
174
+ // Setup an initial chunk usage for JS
175
+ await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
176
+ await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
177
+ await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
180
178
181
- expect ( result ?. success ) . toBe ( true ) ;
182
- harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
183
- harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'modulepreload' ) ;
184
- harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'chunk-' ) ;
185
- } ) ;
179
+ const { result } = await harness . executeOnce ( ) ;
186
180
187
- it ( 'should not generate initial preload link elements when preloadInitial is false' , async ( ) => {
188
- harness . useTarget ( 'build' , {
189
- ...BASE_OPTIONS ,
190
- index : {
191
- input : 'src/index.html' ,
192
- preloadInitial : false ,
193
- } ,
181
+ expect ( result ?. success ) . toBe ( true ) ;
182
+ harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
183
+ harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'modulepreload' ) ;
184
+ harness . expectFile ( 'dist/browser/index.html' ) . content . toContain ( 'chunk-' ) ;
194
185
} ) ;
195
186
196
- // Setup an initial chunk usage for JS
197
- await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
198
- await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
199
- await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
200
-
201
- const { result } = await harness . executeOnce ( ) ;
202
-
203
- expect ( result ?. success ) . toBe ( true ) ;
204
- harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
205
- harness . expectFile ( 'dist/browser/index.html' ) . content . not . toContain ( 'modulepreload' ) ;
206
- harness . expectFile ( 'dist/browser/index.html' ) . content . not . toContain ( 'chunk-' ) ;
207
- } ) ;
187
+ it ( 'should not generate initial preload link elements when preloadInitial is false' , async ( ) => {
188
+ harness . useTarget ( 'build' , {
189
+ ...BASE_OPTIONS ,
190
+ index : {
191
+ input : 'src/index.html' ,
192
+ preloadInitial : false ,
193
+ } ,
194
+ } ) ;
208
195
209
- it ( `should generate 'index.csr.html' instead of 'index.html' by default when ssr is enabled.` , async ( ) => {
210
- await harness . modifyFile ( 'src/tsconfig.app.json' , ( content ) => {
211
- const tsConfig = JSON . parse ( content ) ;
212
- tsConfig . files ??= [ ] ;
213
- tsConfig . files . push ( 'main.server.ts' ) ;
196
+ // Setup an initial chunk usage for JS
197
+ await harness . writeFile ( 'src/a.ts' , 'console.log("TEST");' ) ;
198
+ await harness . writeFile ( 'src/b.ts' , 'import "./a";' ) ;
199
+ await harness . writeFile ( 'src/main.ts' , 'import "./a";\n(() => import("./b"))();' ) ;
214
200
215
- return JSON . stringify ( tsConfig ) ;
216
- } ) ;
201
+ const { result } = await harness . executeOnce ( ) ;
217
202
218
- harness . useTarget ( 'build' , {
219
- ... BASE_OPTIONS ,
220
- server : 'src/main.server.ts' ,
221
- ssr : true ,
203
+ expect ( result ?. success ) . toBe ( true ) ;
204
+ harness . expectFile ( 'dist/browser/main.js' ) . content . toContain ( 'chunk-' ) ;
205
+ harness . expectFile ( 'dist/browser/index.html' ) . content . not . toContain ( 'modulepreload' ) ;
206
+ harness . expectFile ( 'dist/browser/index.html' ) . content . not . toContain ( 'chunk-' ) ;
222
207
} ) ;
223
-
224
- const { result } = await harness . executeOnce ( ) ;
225
- expect ( result ?. success ) . toBeTrue ( ) ;
226
- harness . expectDirectory ( 'dist/server' ) . toExist ( ) ;
227
- harness . expectFile ( 'dist/browser/index.csr.html' ) . toExist ( ) ;
228
- harness . expectFile ( 'dist/browser/index.html' ) . toNotExist ( ) ;
229
208
} ) ;
230
209
} ) ;
231
210
} ) ;
0 commit comments