How can I get my scenarios tag values in a before hook? #1157
-
I have some scenarios to validate some specific bugs opened in Jira and these scenarios are tagged with the bug Id so I can keep track of it. What I want now is to get this tag value in a beforeEach hook and conditionally run my test. Example:
I want to get the "jiraId_001" tag value and skip the test if the string value matches my criteria. With this string value, I can check the item status in Jira and skip the test if the defect is still open. Does anyone know how to get the scenario tag values? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
In cucumber-js, you can skip a test from Before(({ pickle }) => {
if (pickle.tags.some(tag => tag.name === "@foo")) {
return "skip";
}
}); |
Beta Was this translation helpful? Give feedback.
-
Where do I place the Before hook? I tried to add it as a global hook in index.ts but it causes this error: `Error: The following error originated from your test code, not from Cypress.
|
Beta Was this translation helpful? Give feedback.
In cucumber-js, you can skip a test from
Before
hooks, like shown below. This hasn't been implemented here though, but can be tracked at #1159.