Skip to content

Commit

Permalink
chore: upgrade to msw 2.x with new response declaration (#6148)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Feb 7, 2024
1 parent d060427 commit 3d1e0a6
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 179 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"lodash.omit": "4.5.0",
"mermaid": "^9.3.0",
"millify": "^6.0.0",
"msw": "1.3.2",
"msw": "2.1.7",
"pkginfo": "0.4.1",
"plausible-tracker": "0.3.8",
"prop-types": "15.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const setupApi = () => {
testServerRoute(
server,
'/api/admin/projects/default/features/feature/parents',
{},
[],
);
testServerRoute(
server,
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/utils/testServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setupServer, SetupServer } from 'msw/node';
import { rest } from 'msw';
import { http, HttpResponse } from 'msw';

export const testServerSetup = (): SetupServer => {
const server = setupServer();
Expand All @@ -18,9 +18,5 @@ export const testServerRoute = (
method: 'get' | 'post' | 'put' | 'delete' = 'get',
status: number = 200,
) => {
server.use(
rest[method](path, (req, res, ctx) => {
return res(ctx.status(status), ctx.json(json));
}),
);
server.use(http[method](path, () => HttpResponse.json(json, { status })));
};
Loading

0 comments on commit 3d1e0a6

Please sign in to comment.