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

126
Views
¿Cómo cambiar el valor del estado del gancho en broma?

Soy nuevo en bromas. Estoy tratando de cambiar el estado del enlace en broma. Pero no pude encontrar ningún documento para implementar lo mismo. A continuación se muestra mi estado del enlace en la pantalla de inicio de sesión.

 const [form, setForm] = React.useState({ email: "", phoneNumber: "", password: "", signUpType: SignUpType.PHONE_NUMBER, });

Quiero cambiar el estado de signUpType a EMAIL durante la prueba. ¿Cómo se puede lograr esto? Hice lo siguiente

 it("Email validation", () => { const email = "sample.s@abc.com"; // Stub the initial state const stubInitialState = [{ signUpTyp: "EMAIL" }]; React.useState = jest.fn().mockReturnValue([stubInitialState, {}]); const tree = mount( <Provider store={configureStore}> <SignIn /> </Provider> ); expect(tree.find('CustomTextInput[attrName="email"]').prop("value")).toBe( "" ); expect(email).toMatch(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/); });

Pero el código anterior no funciona para mí. Por favor, ayúdenme a encontrar una solución para esto. Además, TextInput será email o número de phoneNumebr según la selección del usuario.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede intentar usar la API jest.spyOn para simular el método React.useState :

 const stubInitialState = [{ signUpTyp: "EMAIL" }]; const mockedSetform = jest.fn(); jest.spyOn(React, 'useState').mockReturnValue([stubInitialState, mockedSetform]);

broma.espiar

about 4 years ago · Juan Pablo Isaza Report
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!