Skip to content

Conversation

@nejidevelops
Copy link
Owner

snyk-top-banner

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:

Issue Score Exploit Maturity
medium severity Information Exposure
SNYK-JS-NODEFETCH-2342118
325 No Known Exploit
Release notes
Package name: msw
  • 0.49.3 - 2023-01-19

    v0.49.3 (2023-01-19)

    Bug Fixes

  • 0.49.2 - 2022-12-13

    v0.49.2 (2022-12-13)

    Bug Fixes

  • 0.49.1 - 2022-11-28

    v0.49.1 (2022-11-28)

    Bug Fixes

  • 0.49.0 - 2022-11-19

    v0.49.0 (2022-11-19)

    Features

  • 0.48.3 - 2022-11-15

    v0.48.3 (2022-11-15)

    Bug Fixes

  • 0.48.2 - 2022-11-13

    v0.48.2 (2022-11-13)

    Bug Fixes

  • 0.48.1 - 2022-11-10

    v0.48.1 (2022-11-10)

    Bug Fixes

  • 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 notes

Important

  • Check the changes in this PR to ensure they won't cause issues with your project.
  • This PR was automatically created by Snyk using the credentials of a real user.
  • Max score is 1000. Note that the real score may have changed since the PR was raised.

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:

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/newtonombese1/project/5b236417-c0d3-45d3-8b86-e26b7bb42c69?utm_source=github&utm_medium=referral&page=upgrade-pr
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @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, performs a substantial upgrade of the msw dependency to its latest stable version, 0.49.3. The primary motivation for this update is to resolve a critical 'Information Exposure' security vulnerability and to bring the project up-to-date with the latest features and stability improvements from the msw library, which have accumulated over the past three years.

Highlights

  • Dependency Upgrade: The msw package has been upgraded from version 0.24.2 to 0.49.3. This is a significant jump, covering 70 versions and approximately three years of development.
  • Security Vulnerability Fix: This upgrade addresses an 'Information Exposure' vulnerability (SNYK-JS-NODEFETCH-2342118) with a score of 325, enhancing the project's security posture.
  • Feature and Bug Fixes: The new msw version includes numerous bug fixes and features introduced over the past three years, such as improved event handling, globalThis.fetch usage, and support for newer TypeScript versions.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades msw from version 0.24.4 to 0.49.3. This is a significant update with several breaking changes that require modifications to your test mock setup. The existing mock handlers for POST and PATCH requests need to be updated to handle req.body as a stream, and the setup for msw server and worker needs to be adjusted to a new API signature. I have left a detailed comment on package.json with the necessary code changes.

"@testing-library/user-event": "^12.1.10",
"mocha": "^8.2.1",
"msw": "^0.24.2"
"msw": "^0.49.3"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Upgrading msw from ^0.24.2 to ^0.49.3 is a major jump that includes several breaking changes. Your existing mock handlers will likely fail without updates. Here are the required changes:

  1. req.body is now a ReadableStream:
    In src/__test__/mocks/handlers.js, your post and patch handlers access req.body directly. This will no longer work. You need to make the handler callbacks async and use await req.json() to parse the body.

    For example, the post handler should be changed from:

    rest.post("http://localhost:4000/items", (req, res, ctx) => {
      id++;
      const item = { id, ...req.body };
      items.push(item);
      return res(ctx.json(item));
    })

    to:

    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));
    })

    A similar change is needed for the patch handler in the same file.

  2. setupServer and setupWorker API change:
    The setupServer and setupWorker functions no longer accept a spread of handlers. You must pass the handlers array directly.

    • In src/__test__/mocks/server.js, change setupServer(...handlers) to setupServer(handlers).
    • In src/__test__/mocks/worker.js, change setupWorker(...handlers) to setupWorker(handlers).
  3. [Recommendation] Migrate from rest to http API:
    The rest API is deprecated as of [email protected]. It's recommended to migrate to the http API for future compatibility. This involves changing import { rest } from 'msw' to import { http } from 'msw' and replacing all rest.* calls with http.* (e.g., rest.get to http.get).

These changes are critical to ensure your tests continue to pass after this dependency upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants