@@ -108,8 +108,8 @@ describe('E2E: execute (internal)', () => {
108108 expect ( response . ok ) . toBe ( true ) ;
109109
110110 const json = ( await response . json ( ) ) as { args : Record < string , string > } ;
111- expect ( json . args . foo ) . toBe ( 'bar' ) ;
112- expect ( json . args . baz ) . toBe ( 'qux' ) ;
111+ expect ( json . args [ ' foo' ] ) . toBe ( 'bar' ) ;
112+ expect ( json . args [ ' baz' ] ) . toBe ( 'qux' ) ;
113113 } ) ;
114114
115115 test ( 'basic authentication' , async ( ) => {
@@ -193,10 +193,12 @@ Accept: application/json
193193 const requests = parse ( content ) ;
194194 expect ( requests ) . toHaveLength ( 1 ) ;
195195
196+ const request = requests [ 0 ] ;
197+ if ( ! request ) throw new Error ( 'Expected request' ) ;
196198 const response = await execute ( {
197- method : requests [ 0 ] ? .method ,
198- url : requests [ 0 ] ? .url ,
199- headers : requests [ 0 ] ? .headers
199+ method : request . method ,
200+ url : request . url ,
201+ headers : request . headers
200202 } ) ;
201203
202204 expect ( response . ok ) . toBe ( true ) ;
@@ -211,11 +213,13 @@ Content-Type: application/json
211213` ;
212214
213215 const requests = parse ( content ) ;
216+ const request = requests [ 0 ] ;
217+ if ( ! request ) throw new Error ( 'Expected request' ) ;
214218 const response = await execute ( {
215- method : requests [ 0 ] ? .method ,
216- url : requests [ 0 ] ? .url ,
217- headers : requests [ 0 ] ? .headers ,
218- body : requests [ 0 ] ? .body
219+ method : request . method ,
220+ url : request . url ,
221+ headers : request . headers ,
222+ ... ( request . body !== undefined && { body : request . body } )
219223 } ) ;
220224
221225 expect ( response . ok ) . toBe ( true ) ;
@@ -275,7 +279,9 @@ describe('E2E: createClient', () => {
275279 expect ( response . ok ) . toBe ( true ) ;
276280
277281 const json = ( await response . json ( ) ) as { args : Record < string , string > } ;
278- expect ( parseInt ( json . args . t , 10 ) ) . toBeGreaterThan ( 0 ) ;
282+ const timestamp = json . args [ 't' ] ;
283+ expect ( timestamp ) . toBeDefined ( ) ;
284+ expect ( parseInt ( timestamp ?? '' , 10 ) ) . toBeGreaterThan ( 0 ) ;
279285 } ) ;
280286
281287 test ( 'client tracks and reuses cookies' , async ( ) => {
@@ -297,7 +303,7 @@ describe('E2E: createClient', () => {
297303 const response = await client . run ( `${ FIXTURES } /get-cookies.http` ) ;
298304
299305 const json = ( await response . json ( ) ) as { cookies : Record < string , string > } ;
300- expect ( json . cookies . session ) . toBe ( 'abc123' ) ;
306+ expect ( json . cookies [ ' session' ] ) . toBe ( 'abc123' ) ;
301307 } ) ;
302308
303309 test ( 'client setVariable updates state' , async ( ) => {
@@ -311,8 +317,8 @@ describe('E2E: createClient', () => {
311317 const response = await client . run ( `${ FIXTURES } /get-with-query.http` ) ;
312318
313319 const json = ( await response . json ( ) ) as { args : Record < string , string > } ;
314- expect ( json . args . a ) . toBe ( 'value2' ) ;
315- expect ( json . args . b ) . toBe ( 'value3' ) ;
320+ expect ( json . args [ 'a' ] ) . toBe ( 'value2' ) ;
321+ expect ( json . args [ 'b' ] ) . toBe ( 'value3' ) ;
316322 } ) ;
317323} ) ;
318324
0 commit comments