frisby: response data extraction and conditional execution

179 Views Asked by At

I'm trying to use frisby to do some testing or automation.

Say I have 2 requests that needs to be executed one after another. However, the first request creates a resource and returns it's URI in the header:

POST /resource

201 
Location: /resource/123

So the way the second call is made depends on the response header of the first one. afterJSON() looks promising but it doesn't seem to handle header. Documentation seems quite short and doesn't mention this. What to do?

1

There are 1 best solutions below

1
On

You can use .after((res) -> ... this will allow you to check response, which will contain headers that you are looking for. Firstly print console.log(res) the response to check if such header exist there and then you can make some operations on it by using: res.headers.theOneThatYouWouldLikeToUse