@@ -78,87 +78,81 @@ describe('start command', () => {
7878 'src/ui/undraw_Developer_activity_re_39tg.svg' ,
7979 ] ,
8080 } ,
81- ] ) (
82- 'should successfully produce bundle assets' ,
83- ( { platform, requests } ) => {
84- const TMP_DIR = path . join (
85- __dirname ,
86- `out/start/${ bundler } /${ platform } `
87- ) ;
88-
89- beforeAll ( async ( ) => {
90- await fs . promises . rm ( TMP_DIR , {
91- recursive : true ,
92- force : true ,
93- } ) ;
94-
95- port = await getPort ( ) ;
96-
97- const config = {
98- root : path . join ( __dirname , '..' ) ,
99- platforms : { ios : { } , android : { } } ,
100- reactNativePath : path . join (
101- __dirname ,
102- '../node_modules/react-native'
103- ) ,
104- } ;
105-
106- const args = {
107- port,
108- platform,
109- logFile : path . join ( TMP_DIR , 'server.log' ) ,
110- webpackConfig : path . join ( __dirname , 'configs' , configFile ) ,
111- } ;
112-
113- // @ts -ignore
114- const { stop } = await startCommand . func ( [ ] , config , args ) ;
115- stopServer = stop ;
116- } ) ;
117-
118- afterAll ( async ( ) => {
119- await stopServer ( ) ;
81+ ] ) ( 'should successfully produce bundle assets' , ( {
82+ platform,
83+ requests,
84+ } ) => {
85+ const TMP_DIR = path . join ( __dirname , `out/start/${ bundler } /${ platform } ` ) ;
86+
87+ beforeAll ( async ( ) => {
88+ await fs . promises . rm ( TMP_DIR , {
89+ recursive : true ,
90+ force : true ,
12091 } ) ;
12192
122- it (
123- `for ${ platform } ` ,
124- async ( ) => {
125- let response = await fetch ( `http://localhost:${ port } /` ) ;
126- await expect ( response . text ( ) ) . resolves . toEqual (
127- 'React Native packager is running'
128- ) ;
129-
130- const [ bundleRequest , ...assetsRequests ] = requests ;
131-
132- response = await fetch ( `http://localhost:${ port } /${ bundleRequest } ` ) ;
133-
134- const responseText = await response . text ( ) ;
135- if ( responseText . length < 100000 ) {
136- console . log ( response , responseText ) ;
93+ port = await getPort ( ) ;
94+
95+ const config = {
96+ root : path . join ( __dirname , '..' ) ,
97+ platforms : { ios : { } , android : { } } ,
98+ reactNativePath : path . join ( __dirname , '../node_modules/react-native' ) ,
99+ } ;
100+
101+ const args = {
102+ port,
103+ platform,
104+ logFile : path . join ( TMP_DIR , 'server.log' ) ,
105+ webpackConfig : path . join ( __dirname , 'configs' , configFile ) ,
106+ } ;
107+
108+ // @ts -expect-error
109+ const { stop } = await startCommand . func ( [ ] , config , args ) ;
110+ stopServer = stop ;
111+ } ) ;
112+
113+ afterAll ( async ( ) => {
114+ await stopServer ( ) ;
115+ } ) ;
116+
117+ it (
118+ `for ${ platform } ` ,
119+ async ( ) => {
120+ let response = await fetch ( `http://localhost:${ port } /` ) ;
121+ await expect ( response . text ( ) ) . resolves . toEqual (
122+ 'React Native packager is running'
123+ ) ;
124+
125+ const [ bundleRequest , ...assetsRequests ] = requests ;
126+
127+ response = await fetch ( `http://localhost:${ port } /${ bundleRequest } ` ) ;
128+
129+ const responseText = await response . text ( ) ;
130+ if ( responseText . length < 100000 ) {
131+ console . log ( response , responseText ) ;
132+ }
133+ expect ( responseText . length ) . toBeGreaterThan ( 100000 ) ;
134+
135+ const responses = await Promise . all (
136+ assetsRequests . map ( ( asset ) =>
137+ fetch ( `http://localhost:${ port } /${ asset } ` )
138+ )
139+ ) ;
140+
141+ responses . forEach ( ( response ) => {
142+ if ( ! response . ok ) {
143+ console . log ( response ) ;
137144 }
138- expect ( responseText . length ) . toBeGreaterThan ( 100000 ) ;
139-
140- const responses = await Promise . all (
141- assetsRequests . map ( ( asset ) =>
142- fetch ( `http://localhost:${ port } /${ asset } ` )
143- )
144- ) ;
145-
146- responses . forEach ( ( response ) => {
147- if ( ! response . ok ) {
148- console . log ( response ) ;
149- }
150- expect ( response . ok ) . toBe ( true ) ;
151- } ) ;
152-
153- (
154- await Promise . all ( responses . map ( ( response ) => response . text ( ) ) )
155- ) . forEach ( ( text ) => {
156- expect ( text . length ) . toBeGreaterThan ( 0 ) ;
157- } ) ;
158- } ,
159- 60 * 1000
160- ) ;
161- }
162- ) ;
145+ expect ( response . ok ) . toBe ( true ) ;
146+ } ) ;
147+
148+ (
149+ await Promise . all ( responses . map ( ( response ) => response . text ( ) ) )
150+ ) . forEach ( ( text ) => {
151+ expect ( text . length ) . toBeGreaterThan ( 0 ) ;
152+ } ) ;
153+ } ,
154+ 60 * 1000
155+ ) ;
156+ } ) ;
163157 } ) ;
164158} ) ;
0 commit comments