-
Notifications
You must be signed in to change notification settings - Fork 0
[Snyk] Upgrade msw from 0.24.4 to 0.49.3 #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Snyk has created this PR to upgrade msw from 0.24.4 to 0.49.3. See this package in npm: msw See this project in Snyk: https://app.snyk.io/org/mohammadnewton/project/8205fad6-188e-46ed-bb29-c5bad44a0be4?utm_source=github&utm_medium=referral&page=upgrade-pr
Summary of ChangesHello @nejidevelops, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request, automatically generated by Snyk, aims to enhance the project's security and maintainability by upgrading the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR upgrades msw from ^0.24.2 to ^0.49.3 to fix a security vulnerability. This is a large version jump that introduces breaking changes. The way msw handles request bodies has changed, and your mock handlers in src/__test__/mocks/handlers.js must be updated to use await req.json() to parse request bodies. Without these changes, your tests will fail. Please see the specific comment for details on the required code modifications.
| "@testing-library/user-event": "^12.1.10", | ||
| "mocha": "^8.2.1", | ||
| "msw": "^0.24.2" | ||
| "msw": "^0.49.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading msw to this version introduces a critical breaking change that will cause your tests to fail.
Starting from [email protected], req.body is a ReadableStream, not a plain object. You must now use await req.json() to parse the JSON body of a request. Your existing handlers in src/__test__/mocks/handlers.js that use req.body directly will need to be updated.
Specifically, the POST and PATCH handlers need to be converted to async functions and use await req.json().
Example for the POST handler:
// src/__test__/mocks/handlers.js
rest.post("http://localhost:4000/items", async (req, res, ctx) => {
id++;
const body = await req.json();
const item = { id, ...body };
items.push(item);
return res(ctx.json(item));
}),Example for the PATCH handler:
// src/__test__/mocks/handlers.js
rest.patch("http://localhost:4000/items/:id", async (req, res, ctx) => {
const { id } = req.params;
if (isNaN(parseInt(id))) {
return res(ctx.status(404), ctx.json({ message: "Invalid ID" }));
}
const itemIndex = items.findIndex((item) => item.id === parseInt(id));
const body = await req.json();
items[itemIndex] = { ...items[itemIndex], ...body };
return res(ctx.json(items[itemIndex]));
}),Please apply these changes to prevent your test suite from breaking.
Snyk has created this PR to upgrade msw from 0.24.4 to 0.49.3.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 70 versions ahead of your current version.
The recommended version was released 3 years ago.
Issues fixed by the recommended upgrade:
SNYK-JS-NODEFETCH-2342118
Release notes
Package name: msw
-
0.49.3 - 2023-01-19
- use EventTarget-based event emitter (#1522) (6a94b8c) @ chrisguttandin
-
0.49.2 - 2022-12-13
- use
-
0.49.1 - 2022-11-28
- setupWorker: resolve the TS4094 error (#1477) (c268796) @ gduliscouet-ubitransport
-
0.49.0 - 2022-11-19
- support TypeScript 4.9, drop support for TypeScript 4.2, 4.3 (#1467) (af0277d) @ wtchnm
-
0.48.3 - 2022-11-15
- SetupApi: validate given request handlers (#1460) (a06a944) @ kettanaito
- inline
-
0.48.2 - 2022-11-13
- resolve absolute worker url against the current path (#1456) (f8d15b4) @ kettanaito
-
0.48.1 - 2022-11-10
- bufferUtils import path (#1453) (91b2902) @ cksal0805
-
0.48.0 - 2022-11-08
-
0.47.4 - 2022-10-04
-
0.47.3 - 2022-09-15
-
0.47.2 - 2022-09-13
-
0.47.1 - 2022-09-10
-
0.47.0 - 2022-09-04
-
0.46.1 - 2022-09-01
-
0.46.0 - 2022-08-31
-
0.45.0 - 2022-08-22
-
0.44.2 - 2022-07-19
-
0.44.1 - 2022-07-14
-
0.44.0 - 2022-07-13
-
0.43.1 - 2022-07-07
-
0.43.0 - 2022-07-04
-
0.42.3 - 2022-06-22
-
0.42.2 - 2022-06-22
-
0.42.1 - 2022-06-07
-
0.42.0 - 2022-05-30
-
0.41.1 - 2022-05-27
-
0.41.0 - 2022-05-22
-
0.40.2 - 2022-05-20
-
0.40.1 - 2022-05-19
-
0.40.0 - 2022-05-17
-
0.39.2 - 2022-03-15
-
0.39.1 - 2022-03-08
-
0.39.0 - 2022-03-07
-
0.38.2 - 2022-03-02
-
0.38.1 - 2022-02-19
-
0.38.0 - 2022-02-19
-
0.36.8 - 2022-01-30
-
0.36.7 - 2022-01-24
-
0.36.5 - 2022-01-19
-
0.36.4 - 2022-01-11
-
0.36.3 - 2021-12-09
-
0.36.2 - 2021-12-08
-
0.36.1 - 2021-12-07
-
0.36.0 - 2021-12-04
-
0.35.0 - 2021-08-21
-
0.34.0 - 2021-08-06
-
0.33.3 - 2021-08-04
-
0.33.2 - 2021-07-31
-
0.33.1 - 2021-07-29
-
0.33.0 - 2021-07-23
-
0.32.3 - 2021-07-23
-
0.32.2 - 2021-07-21
-
0.32.1 - 2021-07-20
-
0.32.0 - 2021-07-13
-
0.31.0 - 2021-07-09
-
0.31.0-beta.0 - 2021-07-02
-
0.30.1 - 2021-07-01
-
0.30.0 - 2021-06-24
-
0.29.0 - 2021-05-23
-
0.28.2 - 2021-04-21
-
0.28.1 - 2021-04-01
-
0.28.0 - 2021-03-25
-
0.27.2 - 2021-03-23
-
0.27.1 - 2021-03-08
-
0.27.0 - 2021-02-25
-
0.27.0-beta - 2021-02-21
-
0.26.2 - 2021-02-08
-
0.26.1 - 2021-02-02
-
0.26.0 - 2021-01-26
-
0.25.0 - 2021-01-04
-
0.24.4 - 2020-12-30
from msw GitHub release notesv0.49.3 (2023-01-19)
Bug Fixes
v0.49.2 (2022-12-13)
Bug Fixes
globalThis.fetchinctx.fetchutility (#1490) (42cdbc7) @ Toxiapo @ kettanaitov0.49.1 (2022-11-28)
Bug Fixes
v0.49.0 (2022-11-19)
Features
v0.48.3 (2022-11-15)
Bug Fixes
statusesdependency during the build (#1458) (99d49f9) @ mattcosta7 @ kettanaitov0.48.2 (2022-11-13)
Bug Fixes
v0.48.1 (2022-11-10)
Bug Fixes
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: