● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'post') ...rest from msw not pointing the type definition even it is correclty imported from node_modules #2207
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, @shruthi-monika. It looks like you are using the latest MSW with the v1 handler syntax ( That syntax has changed since v2.0. Please see https://mswjs.io/docs/migrations/1.x-to-2.x. How to resolve this?You have two options: (Recommended) Option 1: Update your codeFollow the Migration guide I've mentioned before, and update your request handler to use the correct syntax (e.g. Option 2: Downgrade MSWThis is easier but not recommended option. If you downgrade to |
Beta Was this translation helpful? Give feedback.
Hi, @shruthi-monika.
It looks like you are using the latest MSW with the v1 handler syntax (
rest.post
).That syntax has changed since v2.0. Please see https://mswjs.io/docs/migrations/1.x-to-2.x.
How to resolve this?
You have two options:
(Recommended) Option 1: Update your code
Follow the Migration guide I've mentioned before, and update your request handler to use the correct syntax (e.g.
http.post
). This includes how you declare mocked responses as well.Option 2: Downgrade MSW
This is easier but not recommended option. If you downgrade to
msw@^1
, the error will be gone but you won't be able to use newest MSW features. v1 is in a readonly mode, don't use it.