Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

logRoles does not print hidden elements

Aperta
#1,201 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@naorpeled ci sta già lavorando.

Dal 18/6/2023.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, typescript
Ambito
testing-qa

Direzione di ricerca

Inizia dagli entry point logRoles e logRole, in particolare dalla firma TypeScript menzionata nell’issue, e riproduci l’output vuoto con elementi nascosti. Confronta l’output dei ruoli con screen.debug; il lavoro è completato quando gli elementi nascosti sono inclusi come richiesto, il secondo parametro viene accettato e l’output rilevante distingue gli elementi nascosti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
  • @testing-library/react version: 14.0.0
  • Testing Framework and version: Jest 29.4.3
  • DOM Environment: jsdom 29.4.3
Relevant code or config:
const buttons = await waitFor(
    screen.getAllByRole("button", { hidden: true })
);

logRoles(buttons)
What you did:

I was trying to logRoles for a DOM tree with hidden elements. Failed to see the elements show in the roles list.

What happened:

Logging roles for hidden elements produces an empty log.

Reproduction:
  1. Get all elements of a DOM tree including hidden ones. Make sure you have hidden ones.
  2. Log using logRoles
  3. See that some log entries are empty compared to what you see when you screen.debug
Problem description:

If you log an element you found using { hidden: true }, logRoles will not print it. Similarly won't print hidden elements in a DOM tree you pass in. This is the opposite of what I would expect from this tool. I want to know why something may be failing to query, so I want to see everything in the tree.
The logRole function does take a { hidden } parameter and by default is set to false, however the function signature in Typescript does not accept a second parameter.

Suggested solution:

A useful thing would be that hidden was on by default, the function signature would be updated to take the second parameter, and that elements logged that are hidden, report so in the pretty role output.

Lingua principale
JavaScript
Stelle
19.7k
Fork
1.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testing-library/react-testing-library

Tutte le issue di testing-library/react-testing-library

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.