Closed YYOANN closed 4 years ago
Patching the spec.js
file with a synchronous read fixed the problem.
I'm not sure this is is what was intended.
-bodyData.body = fs.createReadStream(file);
+bodyData.body = fs.readFileSync(file);
Edit: removed encoding
@YYOANN Just ran a test with node v13.8.0
and just-api v1.2.5
and it runs as expected.
Here's a sample suite I tried with.
meta:
name: POST raw body requests (json , text, binary )
configuration:
scheme: http
host: 127.0.0.1
port: 3027
specs:
- name: post binary data (file) as body
request:
path: /echoBinaryBodyResponseStats
method: post
headers:
- name: content-type
value: image/png
payload:
body:
type: binary
content: static/assets/logo.png
response:
status_code: 200
json_data:
- path: $.request_content_size
value: 12371
If you are still having issues, please update the issue with an attachment containing your suite so I can take look.
Note: Make sure that the file exists at static/assets/logo.png
in the directory where you invoke tests from
I tried to reproduce the issue today and now everything is working as expected, locally and in docker, I can't figure out what was wrong. I'll update the issue if I find something. Thanks for your help.
It seams impossible to send binary payload. I have directly checked following example:
And it sends
[object Object]
as body payload. Further inspection show that it's afs.ReadStream
object (created inspec.js:515
?). Did I missconfigured something or is it a bug or not fully implemented feature?Tested with
node13
andjust-api@1.2.5
.