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

181
Views
FeatureToggle React Jest - TypeError: no se puede leer la propiedad 'estado' de indefinido

Tengo un componente que usa la featuretoggle-react para renderizar algunas cosas. Por ejemplo:

 import { On, FeatureToggle } from "featuretoggle-react"; const MyComponent = () => { return ( <FeatureToggle feature="my_feature"> <On> // render whatever </On> </FeatureToggle> ) }

Ahora estoy creando pruebas usando Jest para MyComponent . Un ejemplo es el siguiente:

 import React from "react"; import { Provider } from "react-redux"; import { On, FeatureToggle } from "featuretoggle-react"; import { store } from "stores"; test("load my component", async () => { const mockComponent = () => <div></div>; jest.mock("featuretoggle-react", () => mockComponent); render( <Provider store={store}> <FeatureToggle feature="my_feature"> // error is signaled here <On> <MyComponent /> </On> </FeatureToggle> </Provider> ); // assert some stuff but there is an error returning above });

Cuando ejecuto la prueba anterior, obtengo el error resultante como:

TypeError: no se puede leer la propiedad 'estado' de indefinido

Si comento <FeatureToggle feature="my_feature"> desde MyComponent (así como en la prueba), mis pruebas se ejecutan con éxito, por lo que me inclino a creer que se trata de un error debido a <FeatureToggle />

He intentado burlarme usando

 const mockComponent = () => <div></div>; jest.mock("featuretoggle-react", () => mockComponent);

pero sigo teniendo el mismo error.

EDITAR: incluso si no me burlo featuretoggle-react , sigo recibiendo el mismo error.

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!