npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wdio-cucumber-parallel-execution

v3.6.15

Published

WebdriverIO Package to execute Cucumber scenarios in parallel

Downloads

12,442

Readme

wdio-cucumber-parallel-execution

A WebdriverIO capability for running Cucumber scenarios within Single/Multiple Feature Files in parallel.

The capability Segregates the entire Automation Suite into smallest independent chunks (Scenarios) and spawns numerous threads through WebdriverIOs maxInstances feature,thus reducing the Test Execution time drastically and allowing Teams to release much faster.

The Solution is Compatible with multiple versions of Nodejs (Ones supporting Async Await natively as well as ones which do not support it)

Handles merging of reports out of the box and provides a consolidated JSON Report Array, which can be leveraged for Reporting.

Star the repo if you find it useful :)

Installation

npm install wdio-cucumber-parallel-execution --save-dev

Architectural View

ParallelExecution

Assuming 1 Scenario takes 1 minute on Average, Total Execution Time will be 1 minute for 9 Scenarios since  all 9 Scenarios will get executed in parallel

API

The Module contains the following functions:

performSetup

This Feature Creates/Removes the Spec and Temp Folders and puts every Scenario in a seperate Feature File

| Parameter | Type | Details | |----------------------------------|--------|-------------------------------------------------------------------------------------------------| | sourceSpecDirectory | string | glob expression for sourceSpecDirectory | | tmpSpecDirectory | string | Path to temp folder containing the Temporary Feature Files (Gets removed in the next execution) | | tagExpression (optional) | string | Tag expression to parse | | ff (optional) | string | Feature File Name to parse | | lang (optional) | string | Language of sourceSpecDirectory | | cleanTmpSpecDirectory | Boolean| Boolean for cleaning the Temp Spec Directory |

getConsolidatedArray

This Feature clubs the JSON Objects generated by every splitted Feature File and returns a consolidated JSON Array, which can be used for Reporting.

| Parameter | Type | Details | |----------------------------------|--------|---------------------------------------------------------------------------------| | parallelExecutionReportDirectory | string | Path to Parallel Execution Report Directory where all the Reports will be saved |

Usage

Setup

Say, in your webdriverio's config file, put the following code:

wdio.conf.js

const argv = require("yargs").argv;
const wdioParallel = require('wdio-cucumber-parallel-execution');
// The below module is used for cucumber html report generation
const reporter = require('cucumber-html-reporter');
const currentTime = new Date().toJSON().replace(/:/g, "-");

const sourceSpecDirectory = `path/to/featureFilesDirectory`;
const parallelExecutionReportDirectory = `path/to/parallelExecutionReportDirectory`;

let featureFilePath = `${sourceSpecDirectory}/*.feature`;

// If parallel execution is set to true, then create the Split the feature files
// And store then in a tmp spec directory (created inside `the source spec directory)
if (argv.parallel === 'true') {
    tmpSpecDirectory = `${sourceSpecDirectory}/tmp`;
    wdioParallel.performSetup({
        sourceSpecDirectory: sourceSpecDirectory,
        tmpSpecDirectory: tmpSpecDirectory,
        cleanTmpSpecDirectory: true
    });
    featureFilePath = `${tmpSpecDirectory}/*.feature`
}

Get Consolidated JSON Report Array

wdio.conf.js

exports.config = {
    // Runner Configuration

    /**
     * Gets executed once before all workers get launched.
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     */
    onPrepare: () => {
        // Remove the `tmp/` folder that holds the json report files
        removeSync(parallelExecutionReportDirectory);
    },

    /**
     * Gets executed after all workers got shut down and the process is about to exit. An error
     * thrown in the onComplete hook will result in the test run failing.
     * @param {Object} exitCode 0 - success, 1 - fail
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     * @param {<Object>} results object containing test results
     */
    onComplete: () => {

        try{
            let consolidatedJsonArray = wdioParallel.getConsolidatedData({
                parallelExecutionReportDirectory: parallelExecutionReportDirectory
            });

            let jsonFile = `${parallelExecutionReportDirectory}report.json`;
            fs.writeFileSync(jsonFile, JSON.stringify(consolidatedJsonArray));
    
            // The below code is not part of wdio-cucumber-parallel-execution module
            // but is mentioned to show, how it can be used with other reporting modules
            var options = {
                theme: 'bootstrap',
                jsonFile: jsonFile,
                output: `tests/reports/html/report-${currentTime}.html`,
                reportSuiteAsScenarios: true,
                scenarioTimestamp: true,
                launchReport: true,
                ignoreBadJsonFile: true
            };
    
            reporter.generate(options);
        } catch(err){
            console.log('err', err);
        }
    }
}

Pass parallel execution Flag as true

package.json

  "scripts": {
    "test": "command to run your tests with --parallel=true"
  }

License

(The MIT License)

Copyright (c) 2019 Simit Tomar [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2019 Alexander Galichenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.