Replies: 2 comments
-
This sounds more like a feature request to expose the api handler middlewares 🤔 seems like you're using internal files which can change at any time. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I am using internal files. And I called it a bug cause there was no way that I could see to use body without changing the parameter here. But after I posted realized this is Zeit. And probably the wrong place to post, but it might help anyone else that wants to use .body in their tests of next pages/api endpoints. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
Describe the bug
When using api-utils.apiResolver with Jest to test my endpoints, I cannot get a json body to pass through to the handler.
To Reproduce
Use in a serverless now / nextjs project with pages/api component jest test like this:
Expected behavior
When handlerComponentToTest gets the req, it should have a body with above values.
System information
Additional context
If I add lines to api-utils.parseBody function to convert req.body to a stream and pass only that to raw_body_1 call, it works as expected.
Other blockers on the way here were
Had to define
And parseBody only looks for lowercase 'content-type'
Beta Was this translation helpful? Give feedback.
All reactions