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

367
Views
Cómo simular objetos globales con Jest en React Native

tengo la función:

 const someFn = () => { const keys = Object.keys(someObj); // rest of function }

En mi prueba de unidad (con broma), quiero simular el valor de retorno de Object.keys :

 test('some test', () => { jest.mocked(Object.keys).mockReturnValue(['one', 'two']); // rest of test });

Pero eso resulta en el siguiente error:

 TypeError: jest.mocked(...).mockReturnValue is not a function

Por lo general, significa que primero necesito simular la exportación usando jest.mock , pero con el Object global no estoy seguro de cómo hacerlo. Pensé que tal vez:

 global.Object = { keys: jest.fn(), }

Pero eso no parece funcionar en absoluto.

¿Alguna idea de cómo resolver este problema? Gracias :)

about 4 years ago · Juan Pablo Isaza
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!