Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
Jest test if element hidden by overflow is visible

I have a react component that behaves like a slider. I wanna test if one of the elements that is hidden by the overflow is visible or not.

Slider

What I have so far is

const prevBtn = screen.getByRole('button', { name: /prev slide/i })
const juneTwentySix = await screen.findByTestId('Sun 26 Jun')
const juneThird = await screen.findByTestId('Sun 30 Jun')

expect(prevBtn).toBeDisabled()
expect(juneTwentySix).toBeVisible() <-- ok
expect(juneThird).toBeInTheDocument() <-- it's in the DOM, so it's ok to be in the document
expect(juneThird).not.toBeVisible() <-- this is where I want to check if the element is visible or not.

How is this slider built: The parent component has a fixed width: ie 300px, and what makes the child component (the one that contains the dates) is transform: translateX(-${currentSlide * 100}%)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda