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.