In one of our use case, we are trying to read a feature file that's sole purpose is to Authenticate the user. From it's response, I am then extracting token and sessionId information that would be passed as a Header in the next API call.
CallingFeature
RetrieveOffers.feature
And call read('classpath:features/AuthenticateUser.feature')
* def token = response.data.uToken
* def sessionId = response.data.user.uSessionId
* configure headers = call read('classpath:headers.js) {uToken : #(token), uSessionId : #(sessionId)'}
And call read('classpath:features/EligibleOffer.feature)
And path '/api/v1/applyOffer'
And method post
Then status 200
Called Feature
EligibleOffer.feature
Scenario: Validate the user is able to get the eligible offers
Given url baseUrl
And path '/api/v1/offers'
When method get
Then status 200
It is doing all correct, In the sense that it sets up the necessary header information for the api call /api/v1/applyOffer which is in the feature file EligibleOffer.feature but when it tries to hit the api, the following error is coming every time no matter even if I increase the timeout.
ERROR com.intuit.karate - java.net.SocketTimeoutException: Read timed out, http call failed after 20054 milliseconds for url: ...
Solution tried - I tried to configure the timeout but it did not work at all.
However, If I then rewrite my feature file by compiling everything in a single feature file, it works fine. There is no timeout issue at all.
RetrieveOffers.feature
* def token = response.data.uToken
* def sessionId = response.data.user.uSessionId
* configure headers = call read('classpath:headers.js) {uToken : #(token), uSessionId : #(sessionId)'}
Given url baseUrl
And path '/api/v1/offers'
When method get
Then status 200
And path '/api/v1/applyOffer'
And method post
Then status 200