mock arraybuffer response (file download)
See original GitHub issueI have an axios request that looks like:
const res = await axios({
method: 'get',
url: `/reports/${report.id}`,
responseType: 'arraybuffer',
})
const blob = new Blob([res.data], { type: 'text/csv' })
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = report.name
link.click()
How do I write a mock for it? This may be just a documentation issue…
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to mock axios zip download call, using ... - Stack Overflow
I am trying to unit test a method which calls this method and got stuck around mocking the zip download call. The code...
Read more >Binary response type - Recipes - Mock Service Worker Docs
Here is an example of a mocked response that sends a local image: ... 6 // Convert "base64" image to "ArrayBuffer".
Read more >Response.arrayBuffer() - Web APIs - MDN Web Docs
The arrayBuffer() method of the Response interface takes a Response stream ... Note that before playing full audio file will be downloaded.
Read more >ArrayBuffer, binary arrays - The Modern JavaScript Tutorial
ArrayBuffer, binary arrays. In web-development we meet binary data mostly while dealing with files (create, upload, download).
Read more >Angular Testing Snippets: the new HttpClient - Medium
Faking HTTP traffic and verifying for expected requests and responses. ... file upload component showing a progress indicator — when we fake out...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I also have the same question
I guess this can be simple done as: