@@ -10,7 +10,7 @@ jest.mock('formdata-node', () => {
1010 return {
1111 FormData : jest . fn ( ) . mockImplementation ( ( ) => {
1212 const appendedData : Record < string , any > = { } ;
13- const formDataInstance = {
13+ const formDataMethods = {
1414 append : ( key : string , value : any , _filename ?: string ) => {
1515 if ( value && typeof value === 'object' && 'content' in value ) {
1616 // Handle File objects
@@ -20,12 +20,23 @@ jest.mock('formdata-node', () => {
2020 }
2121 } ,
2222 _getAppendedData : ( ) => appendedData ,
23- // Make the instance available through .form
24- form : null as any ,
2523 } ;
26- // Set up circular reference
27- formDataInstance . form = formDataInstance ;
28- return formDataInstance ;
24+
25+ // Create a proxy that handles both direct access and form property access
26+ const proxy = new Proxy ( formDataMethods , {
27+ get : ( target : any , prop : string | symbol ) : any => {
28+ if ( prop === 'form' ) {
29+ // Return a proxy for form property that has all the same methods
30+ return new Proxy ( { } , {
31+ get : ( _ : any , innerProp : string | symbol ) : any => {
32+ return target [ innerProp ] ;
33+ }
34+ } ) ;
35+ }
36+ return target [ prop ] ;
37+ } ,
38+ } ) ;
39+ return proxy ;
2940 } ) ,
3041 File : jest . fn ( ) . mockImplementation ( ( content : any [ ] , name : string ) => ( {
3142 content,
0 commit comments