Skip to content

Bug: FormData - Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob' #31

@todor-a

Description

@todor-a

I'm having issues migrating away from jsdom to jest-fixed-jsdom in order to be able to use msw (I know that migrating away from jsdom altogether is best but this is not feasible at this point).

For this method:

export const uploadDocument = (file: File) => {
    const data = new FormData();
  
    data.append("file", file, file.name);
  };

I get this error:

TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'

      2 |     const data = new FormData();
      3 |   
    > 4 |     data.append("file", file, file.name);
        |          ^
      5 |   };
      6 |   

I've setup a reproduction here and would love some help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions