Skip to content

FormData upload broken after update to msw v2 #6054

@pschyma

Description

@pschyma

Describe the bug

After upgrading msw from 1.x to 2.x FormData upload stopped working in tests. Looking at the debugging output, Axios doesn't append the boundary to the Content-Type header anymore.

The MSW team checked [1] this already on their side.

I tried to append the boundary manually to the header for debugging purposes, but that revealed another issue:

{ "Content-Type": "multipart/form-data; boundary=abc" }

ends in

Content-Type: multipart/form-databoundary=abc

[1] mswjs/msw#1835

To Reproduce

Checkout the msw reproducer at [1] and

cd examples/with-vitest
npm install
npm test

[1] https://github.com/pschyma/msw-examples/tree/axios-formdata-reproducer

Code snippet

No response

Expected behavior

As with msw the boundary is appended to Content-Type header.

Axios Version

1.6.0

Adapter Version

XHR

Browser

jsdom

Browser Version

No response

Node.js Version

18.8.2

OS

Linux

Additional Library Versions

msw 2.0.x
vitest 0.34.6

Additional context/Screenshots

No response

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