The UI I'm working on is rendered differently based on the response received. I would like to test the UI when a 4xx and 5xx responses are received.
My api handler looks something like:
import { rest } from 'msw';
import { items } from './apiValues';
export const handlers = [
rest.get('/items/', (_req, res, ctx) => res(ctx.status(200), ctx.json(items))),
];
This will always return a 2xx response making it unable to test the UI if a 4xx or 5xx response is received, unless I change the handlers manually, which is tiring.
How can tests for 4xx and 5xx responses be tested?