● 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
Answered
by
kettanaito
shruthi-monika
asked this question in
Q&A
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 |
0 replies
Answer selected by
kettanaito
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

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.