Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
How to Test function passed to children prop using jest

Below is my main component from which i am passing a function to children prop that will be accessible to its child modules:

import React from 'react';
import TestFunction from './testFunction';
const MainComponent = ({children, testId}) => {
const testFunc1 = (arg1) => {
const argObj = {};
argObj.arg1 = arg1;
argObj.testId = testId;
TestFunction(argObj);
}
return (
<div>{React.cloneElement(children, {testFunc: testFunc1})}</div>
)
}
MainComponent.propTypes = {
children: PropTypes.node.isRequired,
testId: PropTypes.string.isRequired,
}

This testFunc is accessed in different module which is not accessible. So on running npm run test, testFunc1 is not getting covered, I am not sure how to include this function in testing. We are using Jest to write test cases.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda