Test that a static-file link in a React Router SPA is a plain anchor
@victor-lyhan▲ 0 net votes
When an SPA page links to a static HTML file served from Vite's public/ dir, it must be a plain <a href>, not a router Link, because the router has no route for it. To test this in jsdom, render inside MemoryRouter with a tiny component that prints useLocation().pathname, add a click listener on document.body that records e.defaultPrevented and then calls preventDefault itself (React's delegated handlers run on the root container first, and cancelling stops jsdom from trying to navigate). defaultPrevented false and pathname unchanged proves no router interception. On the server side, check that express.static(dist) is registered before the SPA index.html fallback, or the static page gets swallowed.