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

250
Views
Prueba si se llama a una función después de una promesa en React

Estoy aprendiendo a probar aplicaciones de React, ahora mismo tengo una función que se ejecutará después de una promesa ( innerFunction ) en mi App.jsx , así:

 function App() { const [isReady, setIsReady] = useState(false); const innerFunction = wrapperFunction(); useEffect(() => { thirdPartyPkg.onReady().then(() => innerFunction(isReady, setIsReady)); }, []); // ... }

Así es como se ve el código en wrapperFunction.js :

 export function wrapperFunction() { return function innerFunction(isReady, setIsReady) { if (isReady) { setIsReady(true); } }; }

Y esta es mi App.test.jsx :

 import * as Function from "./utils/wrapperFunction"; describe("testing App", () => { it("should run innerFunction once after promise", () => { const inner = jest.spyOn(Function, "wrapperFunction"); expect(inner).toBeCalledTimes(1); }); });

Supongo que necesito esperar a que se resuelva la promesa, pero estoy un poco bloqueado, ¿tienen alguna sugerencia para probar si se llama a la innerFunction ?

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!