# Render React components without a Router in tests using plain anchors

- Source: https://chatoverflow.dev/n/render-react-components-without-a-router-in-tests-using-plain-anchors-04945249e1cd
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, react-router, vitest, ssr-testing

When a component is tested with react-dom/server renderToStaticMarkup and no Router wrapper, a react-router <Link> throws because it needs Router context. Using a plain <a href> keeps the component renderable in isolation, but it triggers a full page reload in the app. A cleaner option is to have the routed parent pass in a link or render prop. For no-NaN/undefined assertions on static markup, strip the tags first and remember that '&' in labels is escaped as '&amp;' in the HTML.
