11import { fileURLToPath } from 'node:url'
22import { describe , expect , it } from 'vitest'
33import { isWindows } from 'std-env'
4- import { $fetch , createPage , fetch , setup , url } from '@nuxt/test-utils/e2e'
5- import { expectWithPolling } from '../utils'
4+ import { $fetch , createPage , setup , url } from '@nuxt/test-utils/e2e'
65
76const isWebpack =
87 process . env . TEST_BUILDER === 'webpack' ||
98 process . env . TEST_BUILDER === 'rspack'
109
1110const isDev = process . env . TEST_ENV === 'dev'
1211
13- await setup ( {
14- rootDir : fileURLToPath ( new URL ( '../fixtures/spa-loader' , import . meta. url ) ) ,
15- dev : isDev ,
16- server : true ,
17- browser : true ,
18- setupTimeout : ( isWindows ? 360 : 120 ) * 1000 ,
19- nuxtConfig : {
20- builder : isWebpack ? 'webpack' : 'vite' ,
21- spaLoadingTemplate : true ,
22- experimental : {
23- spaLoadingTemplateLocation : 'within' ,
12+ if ( ! isDev ) {
13+ await setup ( {
14+ rootDir : fileURLToPath ( new URL ( '../fixtures/spa-loader' , import . meta. url ) ) ,
15+ dev : isDev ,
16+ server : true ,
17+ browser : true ,
18+ setupTimeout : ( isWindows ? 360 : 120 ) * 1000 ,
19+ nuxtConfig : {
20+ builder : isWebpack ? 'webpack' : 'vite' ,
21+ spaLoadingTemplate : true ,
22+ experimental : {
23+ spaLoadingTemplateLocation : 'within' ,
24+ } ,
2425 } ,
25- } ,
26- } )
27-
28- describe ( 'spaLoadingTemplateLocation flag is set to `within`' , ( ) => {
29- it . runIf ( isDev ) ( 'should load dev server' , async ( ) => {
30- await expectWithPolling ( ( ) => fetch ( '/' ) . then ( r => r . status === 200 ) . catch ( ( ) => null ) , true )
3126 } )
27+ }
28+
29+ describe . skipIf ( isDev ) ( 'spaLoadingTemplateLocation flag is set to `within`' , ( ) => {
3230 it ( 'should render loader inside appTag' , async ( ) => {
3331 const html = await $fetch < string > ( '/spa' )
3432 expect ( html ) . toContain ( `<div id="__nuxt"><div data-testid="loader">loading...</div></div>` )
@@ -38,17 +36,14 @@ describe('spaLoadingTemplateLocation flag is set to `within`', () => {
3836 const page = await createPage ( )
3937 await page . goto ( url ( '/spa' ) )
4038
41- const loader = page . getByTestId ( 'loader' )
42- const content = page . getByTestId ( 'content' )
43-
44- await loader . waitFor ( { state : 'visible' } )
45- expect ( await content . isHidden ( ) ) . toBeTruthy ( )
39+ await page . getByTestId ( 'loader' ) . waitFor ( { state : 'visible' } )
40+ expect ( await page . getByTestId ( 'content' ) . isHidden ( ) ) . toBeTruthy ( )
4641
4742 await page . waitForFunction ( ( ) => window . useNuxtApp ?.( ) && window . useNuxtApp ?.( ) . isHydrating )
4843
49- expect ( await content . isHidden ( ) ) . toBeTruthy ( )
44+ expect ( await page . getByTestId ( ' content' ) . isHidden ( ) ) . toBeTruthy ( )
5045
51- await content . waitFor ( { state : 'visible' } )
46+ await page . getByTestId ( ' content' ) . waitFor ( { state : 'visible' } )
5247
5348 await page . close ( )
5449 } , 60_000 )
0 commit comments