How can we call multiple requests in one scenario while using cucumber with pactumjs? #172
-
When using Cucumber (BDD style) we may have some Scenario like Scenario: Naigate to all pages
Given I make a GET request to /orders
And I set query param size to 20
And I set query param page to 1
And I set header Authorization to Bearer $S{sellerToken}
When I receive a response
Then I expect response should have a status 200
And Response should return within 500 milliseconds
Given I make a GET request to /products
And I set query param size to 20
And I set query param page to 1
And I set header Authorization to Bearer $S{sellerToken}
When I receive a response
Then I expect response should have a status 200
And Response should return within 500 milliseconds The problem is the second request seem not working in same Scenario. Any idea to resolve this issue? |
Beta Was this translation helpful? Give feedback.
Answered by
ASaiAnudeep
Jun 17, 2022
Replies: 1 comment
-
Hello @ttran1410 , The easiest way to solve is by re-initiating the Given(/^I make a (.*) request to (.*)$/, function (method, endpoint) {
spec = pactum.spec();
spec[method.toLowerCase()](endpoint);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ttran1410
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @ttran1410 ,
The easiest way to solve is by re-initiating the
spec
with a new instance inside theGiven
step definition.