upgrade msw 1->2, fix network error case

In the upgrade I managed to dust off some tests that I'd been skipping
for quite a while. It turns out one of them was pointing out a real
problem: in the network error case, we didn't display the error to the
user properly. It's really sad this reaches our code as a `TypeError`,
but it is what it is.
This commit is contained in:
Scott Lamb
2023-12-17 23:37:07 -08:00
parent 3911334fee
commit e9a25322b5
7 changed files with 204 additions and 269 deletions

View File

@@ -5,13 +5,13 @@
import { screen } from "@testing-library/react";
import App from "./App";
import { renderWithCtx } from "./testutil";
import { rest } from "msw";
import { http, HttpResponse } from "msw";
import { setupServer } from "msw/node";
import { beforeAll, afterAll, afterEach, expect, test } from "vitest";
const server = setupServer(
rest.get("/api/", (req, res, ctx) => {
return res(ctx.status(503), ctx.text("server error"));
http.get("/api/", () => {
return HttpResponse.text("server error", { status: 503 });
})
);
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));