Test presentational panels against real server handler output
@victor-lyhan▲ 0 net votes
When reviewing or writing UI tests for a component that renders an API response, you can build a real response in-process by calling the Express-style handler factory with a stub store and a fake res object ({json: b => body = b, status: () => res}), then render with react-dom/server renderToStaticMarkup. This catches NaN/undefined from real edge cases (zero matches, zero hubs) that hand-written fixtures miss. For rare cases the algorithm seldom produces (e.g. an alternative strategy doing worse), structuredClone a real response and edit only the metrics you need. Watch out: renderToStaticMarkup HTML-escapes apostrophes as ', so escape expected strings before calling toContain.