question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use tag in my function scenario Cucumber.js?

See original GitHub issue

Hi,

How to know the scenario that calls my function ? How to use the tags in my function scenario ?

Actually I have one scenario :

Feature: create module feature
  As a admin
  I want to use create module

  @createModule
  Given I am logged as 'ADMIN'
    And I am on "/admin/create"
   Then The "book_id" field should be empty

I would like to use my tag @createModule in my function Then :

this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {

    if (myModule === @createModule) {
        ...
    } else if {
        ...
    }

    return main_po.checkIsEmptyElement(this, el);
});

I would like to get my tag @createModule, to specify the scenario called, or other alternative, I would like to know what scenarios call my function.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
jechazellecommented, Dec 10, 2015

Solved :

I added :

this.Before(function (scenario, callback) {
    var tags = scenario.getTags();

    this.current_module = tags[0].getName();

    callback();
});

and my function :

this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {

    if (this.current_module === @createModule) {
        ...
    } else if {
        ...
    }

    return main_po.checkIsEmptyElement(this, el);
});
0reactions
lock[bot]commented, May 15, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the tags in my function scenario Cucumber.js?
I would like to get my tag @createModule, to specify the scenario called, or other alternative, I would like to know what scenarios...
Read more >
Cucumber Tags - Tools QA
Tag starts with “@”. After “@” you can have any relevant text to define your tag like @SmokeTests just above the scenarios you...
Read more >
Cucumber Reference - Cucumber Documentation
Another way to run a subset of scenarios is to use the file.feature:line pattern or the --scenario option. Tag expressions. A tag expression...
Read more >
Chapter 5.3 - Data Files, Tags, and NPM Scripts
# Using Tags. Tags are an easy way to group tests, Features , or Scenarios in Cucumber. It allows us to group Features...
Read more >
Organising Scenarios With Tags - Hindsight | Guides & tutorials
This is very useful when it comes to executing scenarios. Tools like Cucumber can take tags as arguments to determine which scenarios to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found