Search code examples
protractorbddcucumberjs

Protractor-CucumberJS - Tagged scenarios - Browser Launched for Scenarios not Tagged


We have a Protractor-CucumberJS framework using BDD feature files and need to create a suite of sanity tests by tagging the relevant scenarios as '@sanity' in feature files and run only the scenarios with this tag.

With this setup, Protractor launches the browser for each feature file one by one, checks if it contains the '@sanity' tag and closes the browser if tag not found and so on.

This will take up a lot of time as there are close to 200 feature files and hence we want the the browser to launch only if the feature file contains the required tag and not otherwise.

Is there a way to achieve that.

Config file -

exports.config = {
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    specs: [../features/*.feature]  
    cucumberOpts: {
        require: [
            '../step-definitions/**/*_Steps.js',
            'generateJsonReport.js'
        ],
        format: 'pretty',
        tags: ['@sanity'],
    },

    multiCapabilities: [{
        browserName: 'chrome',
        shardTestFiles: true,
    }
    ],

    onPrepare: function () {
        browser.driver.manage().window().setSize(1600, 800);
    }
 };

Solution

  • This is not possible due to the fact that you are using the option shardTestFiles:true, see the config.

    If you disable it, or remove it, it will first search all the files (without parsing all files and opening a browser for it) for your specific tag and only run the featurefiles that have that tag.