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

119
Views
¿Cómo cambio un valor en una sola prueba después de que se ha simulado un módulo?

Me estoy burlando de un componente que está disponible en un paquete npm:

 jest.mock('@paypal/react-paypal-js', () => { const reactPaypalJs = jest.requireActual('@paypal/react-paypal-js'); return { ...reactPaypalJs, PayPalButtons: (props) => { return ( <button type="button" onClick={() => { props.onApprove({ subscriptionID: '123' }); }} > Confirm PayPal Payment </button> ); }, }; }); describe('Subscribe Page', () => { it('should expect a subscription ID of 123', async () => { render(<PaymentPage />); // Simulate filling out the paypal form using the mock and then submit it userEvent.click(screen.getByRole('button', { name: 'Confirm PayPal Payment' })); await waitFor(() => { expect(trackEventStub).toHaveBeenLastCalledWith({ name: Events.PaymentSuccess, properties: { paymentPlatform: 'PayPal', }, }); }); }); });

Quiero cambiar el valor de lo que se envía a prop.onApprove cuando se hace clic en el botón en una sola prueba. ¿Cómo puedo hacer eso?

Preferiría no tener que redefinir PayPalButtons para cada prueba en la que quiera cambiar el ID de subscriptionID , pero si es necesario, lo haré. Simplemente no puedo entender cómo cambiarlo para las pruebas individualmente.

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!