[BUG]: Missing ResizeObserver guard in Navbar causes App.test.jsx test suite failure under jsdom

Aperta
#456 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@AyushSrivastava1818 ci sta già lavorando.

Dal 14/11/2026.

  • #457 di @AyushSrivastava1818 — aperta
  • #468 di @prasanm1423 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript, react

Direzione di ricerca

The failure comes from the new ResizeObserver(measureOverflow) call inside the useEffect in src/components/Navbar.jsx, which jsdom does not provide. Read src/test/setup.js and vite.config.js to see how the test environment is set up, then run src/App.test.jsx to reproduce. Done means the suite passes; a linked pull request (#457) already targets this, so check it before starting.

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

Descrizione

bug
Bug Description

In src/components/Navbar.jsx, new ResizeObserver(measureOverflow) is instantiated directly inside useEffect:

const observer = new ResizeObserver(measureOverflow)
observer.observe(navbar)
observer.observe(links)
measureOverflow()
return () => observer.disconnect()

While ResizeObserver is supported natively in modern browsers, jsdom (which Vitest uses as configured in vite.config.js) does not implement ResizeObserver. Furthermore, src/test/setup.js does not provide a mock or polyfill for it.

As a result, running npm test fails with an uncaught ReferenceError: ResizeObserver is not defined when mounting <Navbar /> in src/App.test.jsx.

Steps to Reproduce
  1. Clone the repository on a clean environment.
  2. Run npm ci.
  3. Run npm test.
  4. Observe the failure in src/App.test.jsx.
Logs and Screenshots
FAIL src/App.test.jsx > App routing > renders the Not Found page for an unknown route
ReferenceError: ResizeObserver is not defined
 ❯ src/components/Navbar.jsx:49:22
     47|     }
     48|
     49|     const observer = new ResizeObserver(measureOverflow)
       |                      ^
     50|     observer.observe(navbar)
     51|     observer.observe(links)

Test Files  1 failed | 11 passed (12)
Tests       1 failed | 97 passed (98)

Suggested fix:

  1. Guard ResizeObserver in src/components/Navbar.jsx:
if (typeof ResizeObserver === 'undefined') {
  measureOverflow()
  return
}
const observer = new ResizeObserver(measureOverflow)
observer.observe(navbar)
observer.observe(links)
measureOverflow()
return () => observer.disconnect()
  1. Or provide a stub mock in src/test/setup.js:
global.ResizeObserver = class ResizeObserver {
  observe() {}
  unobserve() {}
  disconnect() {}
}
Environment Details
  • Node.js version: 18+ / 20+
  • Test Runner: Vitest / jsdom
  • OS: Windows / Linux / macOS
  • Branch: main
Impact

Low - Minor inconvenience

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Lingua principale
JavaScript
Stelle
53
Fork
182
Merge medio
18m
PR unite (30g)
2

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 AOSSIE-Org/OrgExplorer

Tutte le issue di AOSSIE-Org/OrgExplorer

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.