fetchをモックするとかでHTMLを含んだResponseを作るのにReactDOMServerのrenderToStaticMarkupが使える
#short
WHATWG Fetchの fetch (じゃなくてもいいけど)をモックするとき Response オブジェクトを作る必要がある
第1引数に渡す bodyInit は <html><head><title>Hoge</title></head></html> とかHTMLを文字列で書いてもいい
しかし、そういえばReactアプリを作っているならReactDOMServerにある renderToStaticMarkup を使うとHTML構造を表現するのにJSXが使えて嬉しいかも
code:tsx
new Response(
renderToStaticMarkup(
<html>
<head>
<title>Example</title>
</head>
</html>,
),
{ headers: { "Content-Type": "text/html" } },
)