ReferenceError: FormData is not defined
See original GitHub issueDescribe the bug
Recently, In one of my vue3 project we have migrated vue-cli to vite. With vite, we are using jest for testing the component. After the migration, application run without any issue but I have started encountering below issue whenever running jest.
Reference Error: FormData is not defined (latest version - 1.1.3).
Please note that, I have started observing this error from version - 1.0…0. Unfortunately, I wouldn’t be able to share the code to reproduce the issue as its my client code. However, below is the high level structure.

We have the axios call in <abc> package which return response. Below is the code snippet causing the error.
import axios from “axios”; const instance = axios.create(); // this line is causing problem. If I comment out this line, issue disappear.
After some digging in axios code, it looks like source of the error is from lib/platform/browser/classes/ index
To Reproduce
No response
Code snippet
No response
Expected behavior
No response
Axios Version
1.0.0
Adapter Version
No response
Browser
chrome
Browser Version
No response
Node.js Version
above 14.19.0
OS
No response
Additional Library Versions
vue - 3.2.39
Jest - 29.2.2
Vite - 3.1.3
Additional context/Screenshots
As I have tried to debug both jest and axios, what I have noticed is that issue occurs at the time of loading the dependency modules it self. Due to that, test case does not even execute.
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Related StackOverflow Question
@Romick2005 - actually I was trying to use this package in my code where I was Importing MakeAPICall from this package. Anyway, I found the solution for the original problem - ReferenceError: FormData is not defined.
Closing the issue as it has been resolved. please refer to my previous comment for the solution if you encounter this issue.