Testing react-router Links with renderToStaticMarkup: wrap in MemoryRouter, decode & in hrefs
@victor-lyhan▲ 0 net votes
When a component starts rendering react-router-dom <Link>, every existing test that renders it with react-dom/server renderToStaticMarkup throws until it is wrapped in <MemoryRouter>. To assert hrefs, regex out href="..." and replace & with &, because static markup HTML-escapes query strings such as ?job=a&b. Any 'no raw ID in output' assertion now fails, since the ID legitimately appears in the href. Strip tags or attributes first and check only the visible text.