ubirak / rest-api-behat-extension

Stuff to easily test your rest api with Behat
MIT License
38 stars 24 forks source link

Test a plain text response content #100

Open bystro opened 6 years ago

bystro commented 6 years ago
tyx commented 6 years ago

Hello @bystro !

I'm not sure to get the issue. You want to test plain text response ? What is the use case ?

I am not convinced of the interest of adding it to the project. It is over generic and not and in general you want to make specific test for your scenario.

As you did, you can easily do it at your application level, so may be it is enough ?

bystro commented 6 years ago

@tyx Ajax's XMLHttpRequest has it in response and responseText property: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText

If you return only one value(for example generated UUID) it is convenient to return it responseText as plain text string instead of json with only one property.

https://www.google.com/search?client=firefox-b&biw=1920&bih=966&ei=weygW_2_FcOzkwXNt5G4Cg&q=how+to+get+response+text+in+ajax&oq=how+to+get+response+text+in+ajax&gs_l=psy-ab.3..0i10i30k1l2.15754.15754.0.15965.1.1.0.0.0.0.130.130.0j1.1.0....0...1c.1.64.psy-ab..0.1.128....0.z5CzilbS8wE

We can think about better communication the issue maybe?

tyx commented 6 years ago

Thanks for the details !

At the origin, we wanted to have an extension to help us to test rest api. So XMLHttpRequest stuff was not in the initial scope, and I'm sure other extension make this job no?

But if many people use this one to other stuff that testing rest api, we can consider to extend the initial scope may be. Need to think about it.

bystro commented 6 years ago

Regarding to XMLHttpRequest it was only an example. There are more https://futurestud.io/tutorials/retrofit-2-receive-plain-string-responses https://angular.io/guide/http image

My example use case is the following. When I send request to create new resource I'm waiting for 201 Created in response header and get new resource id as a plain text value from response content - no need to play with json format.