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

217
Views
Simular getSignedUrl del archivo de almacenamiento de Google usando Jest

Tengo un fragmento de código que hace uso de getSignedUrl

 onst [url] = await blob.getSignedUrl({ action: 'read', expires: Date.now() + 60 * 1000, contentType: mimetype })

Desafortunadamente, el emulador de Firebase no puede firmar la URL, mi solución es simular el valor de retorno de blob.getSignedUrl

Como sigue

 import { File } from '@google-cloud/storage' jest.mock('File', () => ({ ...jest.requireActual('@google-cloud/storage'), getSignedUrl: jest.fn().mockReturnValue({ url: 'http://' }), }))

Aunque esto no tiene ningún efecto. ¿Cómo puedo simular la función getSignedUrl?

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

0

jest.mock toma el nombre del módulo (o la ruta) como parámetro.

Supongo que lo que querías hacer es usar un espía:

 import { File } from '@google-cloud/storage' const spy = jest.spyOn(File.prototype, 'getSignedUrl') spy.mockReturnValue({ url: 'http://' }) // if you dont need to keep spy you can do it in one line : // jest.spyOn(File.prototype, 'getSignedUrl').mockReturnValue({ url: 'http://' })
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!