Reputation: 419
I am looking for a way in cucumber.js to store a value in the scenario scope and then reuse it in the feature file as a step parameter like the following example:
Then I expect that element "element" matches the text {{scenarioscopeveribale[A]}}
Thanks!
Upvotes: 1
Views: 965
Reputation: 22953
Using https://github.com/apickli/apickli, you can just use as myvalue1 in global scope
and myvalue1
to share data between scenarios:
Feature: test
Scenario: 1
Given I set X-Input-1 header to value1
And I set X-Input-2 header to value2
When I POST to /post
Then I store the value of body path $.headers.X-Input-1 as myvalue1 in global scope
And I store the value of body path $.headers.X-Input-2 as myvalue2 in global scope
Scenario: 2
Given I set headers to
| name | value |
| X-Test1 | `myvalue1` |
| X-Test2 | `myvalue2` |
When I POST to /post
Then response body path $.headers.X-Test1 should be value1
And response body path $.headers.X-Test2 should be value2
Example from https://github.com/apickli/apickli/issues/63#issuecomment-247964322
More examples here https://github.com/apickli/apickli/blob/master/source/test/features/injecting-variables.feature
Upvotes: 0
Reputation: 1475
What you're looking for is the World the intended way of sharing between scenarios, what you put in your world, though "this", is going to be shared between scenarios.
Upvotes: 0