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

287
Vistas
Why are material UI components not rendered in jsdom when using Jest?

I am using Jest/React Testing Library to test the UI.

I have a component whose return statement looks like this:

const sidebarContentUp = (
    <Drawer
      anchor="left"
      onClose={onMobileClose}
      open={openMobile}
      PaperProps={{
        sx: {
          backgroundColor: 'background.paper',
          width: 280,
        },
      }}
      variant="temporary"
      data-testid="drawer-up"
    >
      {content}
    </Drawer>
  );

  const sidebarContentDown = (
    <Drawer
      anchor="left"
      open
      PaperProps={{
        sx: {
          backgroundColor: 'background.paper',
          height: 'calc(100% - 64px) !important',
          top: '64px !Important',
          width: 280,
        },
      }}
      variant="persistent"
    >
      {content}
    </Drawer>
  );

  return (
    <>
      {process.env.NEXT_PUBLIC_IS_TESTING ? (
        <Grid>
          <div>div2</div>
          {sidebarContentUp}
          {/* {sidebarContentDown} */}
          <div>div3</div>
        </Grid>
      ) : (
        <>
          <Hidden lgUp>{sidebarContentUp}</Hidden>
          <Hidden lgDown>{sidebarContentDown}</Hidden>
        </>
      )}
    </>
  );
};

There are no hidden attributes or anything for sidebarContentUp, but it is never rendered in the jsdom when running tests.

I only see div2 and div3

I could not figure out for days.

Why is it not rendered, and how can I fix this?

Another issue that might give more hints is that when I don't have {sidebarContentDown} commented out, it throws an error

 Error: Uncaught [TypeError: Cannot read property 'includes' of undefined]
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