Conversation
|
ready for testing: codeceptjs@3.6.4-beta.2 |
There was a problem hiding this comment.
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.
What if data is not JSON? But encoded form?
There was a problem hiding this comment.
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
› [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,"_readableState":{"state":6176,"highWaterMark":65536,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":false,"errored":null,"defaultEncoding":"utf8","awaitDrainWriters":null,"decoder":null,"encoding":null},"_events":{},"_eventsCount":3}],"writable":false,"readable":true,"dataSize":0,"maxDataSize":2097152,"pauseStreams":true,"_released":false,"_streams":["----------------------------807986065015258526651649\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,"_readableState":{"state":6176,"highWaterMark":65536,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":false,"errored":null,"defaultEncoding":"utf8","awaitDrainWriters":null,"decoder":null,"encoding":null},"_events":{},"_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":"--------------------------807986065015258526651649"}'Applicable helpers:
Type of change
Checklist:
npm run docs)npm run lint)npm test)