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