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

124
Views
Probando React-form-hook para Select en Enzyme y broma con Controller API

Quiero probar mi siguiente evento Seleccionar y simular en cambio. pero actualmente el onchange no está funcionando. Al seleccionar cierta opción del menú desplegable, quiero mostrar un campo de entrada, pero no puedo simular un evento de cambio. Todo funciona bien en el archivo JSX. pero no se simuló correctamente en el archivo de prueba.

 const accType = watch('accountType'); <Controller control={control} name="accountType" label="Account Type" rules={{ required: true }} render={({ onChange, ref }) => ( <Select onChange={(e) => onChange(e.target.value)} className={styles.w100} defaultValue={bankAccountTypes[0]} > {bankAccountTypes.map((type) => ( <MenuItem key={type} value={type}> {type} </MenuItem> ))} </Select> )} /> { accType === 'NRO Savings Account' ? ( <Grid item={true} xs={12} className={`${styles.fieldItem}`}> <TextField InputLabelProps={{ shrink: true }} className={styles.w100} type="text" name="country" required={true} label="Country" inputRef={register({ required: true })} /> </Grid> ) : null }

A continuación se muestra mi archivo de prueba

 // Country Field should be hidden let country = component.find({ name: 'country' }); expect(country).toHaveLength(0); // Simulate Account type field to display Country Dropdown await act(async () => { accountType.simulate('change', { value: 'NRO Savings Account' }); }); // Country field should be present now country = component.find({ name: 'country' }); expect(country).toHaveLength(1); //Expected length: 1 //Received length: 0

Estoy usando Jest y Enzyme aquí en React

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!