Error: Duplicate request initiated. #96
-
Hello guys, I am using pactum-cucumber-boilerplate project and trying to create scenario like this: Scenario: Store email value in variable I am getting: Error: Duplicate request initiated. Existing request - GET https://reqres.in/api/users/1 I have 2 questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
To send more requests in a single scenario, just re-initiate the spec object in the appropriate step definition. When(/^I make a (.*) request with body to (.*)$/, function (method, endpoint, body) {
spec = pactum.spec();
spec.withMethod(method);
spec.withPath(endpoint);
spec.withBody(body);
}); More details here
Use data stores. Scenario: Get A User
Given I make a GET request to /api/users/1
When I receive a response
Then I expect response should have a status 200
And I store response at data.email as UserEmail
Scenario: List Users
Given I make a GET request to /api/users
And I set query param email to $S{UserEmail}
When I receive a response
Then I expect response should have a status 200 From the above example the email id from the server is saved in pactum's data-store. You can refer them in the next scenario as |
Beta Was this translation helpful? Give feedback.
-
Currently I have a function: When(/^make a (.) request to (.)$/, function (method, endpoint) { But get error message: × When make a GET request to /api/breeds/image/random # features\support\steps.js:39 What I am doing wrong? |
Beta Was this translation helpful? Give feedback.
To send more requests in a single scenario, just re-initiate the spec object in the appropriate step definition.
More details here
Use data stores.