-
-
Notifications
You must be signed in to change notification settings - Fork 742
feat(rest): print curl #4396
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(rest): print curl #4396
Conversation
ready for testing: codeceptjs@3.6.4-beta.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good to me
I checked alternative implementation at https://github.com/anthonygauthier/axios-curlirize/blob/master/src/lib/CurlHelper.js and I think your is better yet minimal.
However, I can assume it doesn't cover all cases.
Should we inform users somehow on that?
Or I have a better idea, ignore CURL output if request is not JSON. I don't think we need to fit for all cases
} | ||
|
||
if (request.data) { | ||
curl += `-d '${JSON.stringify(request.data)}'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if data is not JSON? But encoded form?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that won't be a problem with encoded form, the curl will look like this.
› [CURL Request] curl --location --request POST https://httpbin.org/post -H "X-API-Key: apiKey-onRequest" -H "Content-Type: application/json" -d '{"_overheadLength":161,"_valueLength":0,"_valuesToMeasure":[{"fd":null,"path":"/Users/t/Desktop/projects/codeceptjs-rest-demo/src/fixtures/test_image.png","flags":"r","mode":438,"end":null,"bytesRead":0,"_events":{},"_readableState":{"highWaterMark":65536,"buffer":[],"bufferIndex":0,"length":0,"pipes":[],"awaitDrainWriters":null},"_eventsCount":3}],"writable":false,"readable":true,"dataSize":0,"maxDataSize":2097152,"pauseStreams":true,"_released":false,"_streams":["----------------------------917245260724904416987426\r\nContent-Disposition: form-data; name=\"attachment\"; filename=\"test_image.png\"\r\nContent-Type: image/png\r\n\r\n",{"source":{"fd":null,"path":"/Users/t/Desktop/projects/codeceptjs-rest-demo/src/fixtures/test_image.png","flags":"r","mode":438,"end":null,"bytesRead":0,"_events":{},"_readableState":{"highWaterMark":65536,"buffer":[],"bufferIndex":0,"length":0,"pipes":[],"awaitDrainWriters":null},"_eventsCount":3},"dataSize":0,"maxDataSize":null,"pauseStream":true,"_maxDataSizeExceeded":false,"_released":false,"_bufferedEvents":[{"0":"pause"}],"_events":{},"_eventsCount":1},null],"_currentStream":null,"_insideLoop":false,"_pendingNext":false,"_boundary":"--------------------------917245260724904416987426"}'
updated as proposed! |
Motivation/Description of the PR
Applicable helpers:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)