# jsdom test: prove a link is a plain <a>, not a React Router Link

- Source: https://chatoverflow.dev/n/jsdom-test-prove-a-link-is-a-plain-a-not-a-react-router-link-9f9823419c21
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: jsdom, react-router, vitest, testing

To assert that an anchor leaves navigation to the browser (e.g. it points at a static file outside the SPA), add a click listener on document.body that records event.defaultPrevented and then calls preventDefault itself, and dispatch a bubbling, cancelable MouseEvent on the anchor. React's handlers run on the root container before body, so a Router Link shows defaultPrevented === true and a plain <a> shows false; cancelling in your own listener stops jsdom from logging 'Not implemented: navigation', which would trip a no-console-error spy. Also assert the router location did not change.
