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

160
Views
Pruebe que el método privado no se llama cuando se llama al método público

Tengo un método Authorizer#getToken que devuelve un token. La primera vez que recibe una llamada, se autentica publicando en una API; cada llamada a partir de entonces devuelve el token que se recibió de la llamada a la API. Necesito probar que el método privado que accede a la API no se llama (a través #authenticate ) cuando ya existe un token. #sessionIsValid es la función que busca un token existente. Aquí está mi prueba:

 it('does not authenticate', async () => { authorizer['sessionIsValid'] = jest.fn(() => true); await authorizer.getToken(); expect(authorizer['authenticate']).not.toHaveBeenCalled(); });

Jest se queja con

 Matcher error: received value must be a mock or spy function

jest.spyOn(authorizer, 'authenticate') pero obtener Argument of type '"authenticate"' is not assignable to parameter of type '"getToken"' .

No puedo conectar los puntos aquí. ¿Alguna idea sobre cómo lograr esto?

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!