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

245
Views
¿Cómo bloquear una función "child_process" con Sinon, hasta el tiempo de espera?

Tengo una función que usa el método exportado execFile del paquete child_process . Quiero probar mi función. Para probarlo, necesito agregar el execFile , por lo que regresará solo después de 5 segundos.

Algo como esto:

 const statStub = sinon.stub(child_process, 'execFile').callsFake(( file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null, callback: ((error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null, ) => { sleepSomehow(5); return execFile(file, args, options, callback); })

No estoy seguro de que sea la forma correcta y, además, no puedo implementar esta función sleepSomehow . Entonces, ¿cómo execFile para detener solo 5 segundos?

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!