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

Open
#456 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@AyushSrivastava1818 is already working on this.

Since Nov 14, 2026.

  • #457 by @AyushSrivastava1818 — open
  • #468 by @prasanm1423 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, react

Research direction

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.

Written by the indexing model from the issue text.

Description

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
Dominant language
JavaScript
Stars
53
Forks
187
Avg merge
18m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/OrgExplorer

All issues in AOSSIE-Org/OrgExplorer

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.