Skip to content

Experimental test mode does not work with new versions of MSW #63338

@gabezeck

Description

@gabezeck

Link to the code that reproduces this issue

https://github.com/gabezeck/next-playwright-testmode-msw

To Reproduce

  1. Run npm run test from the root of the repo
  2. This should run the only test file, which is here.
  3. This ends up triggering an error when hitting this portion of the testmode code:
    const mockedRequest = new MockedRequest(new URL(request.url), {

It results in a "TypeError: _msw.MockedRequest is not a constructor" error, which occurs because MockedRequest is no longer a constructor in MSW > 2.0.

Current vs. Expected behavior

The current behavior results in the tests failing with the error outlined above. I would expect the testmode code to be updated to correctly create mocked requests based upon the current version of the package.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.0-canary.23 // Latest available version is detected (14.2.0-canary.23).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions