Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
How to mock axios zip download call, using axios-mock-adaptor?

I have a code which is downloading the zip as arraybuffer and subsequently uses admZip to get the files inside. I am trying to unit test a method which calls this method and got stuck around mocking the zip download call.

The code is -

export const downloadZip = async (zipUrl: string): Promise<Buffer>  => {
  const axiosInstance = axios.create({ headers: getHeaders() });
  const body = await axiosInstance.get(zipUrl, {
    responseType: 'arraybuffer'
  });
  
  return body.data
}

Does anyone have any prior experience on this and can help?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This may help.

const mock = new MockAdapter(axiosInstance);
mock.onGet("https://zip_url").reply(200, {data: "zipData"});

await expect(AxiosClient().get("https://zip_url")).tobe({data: "zipData"})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!