Coder Social home page Coder Social logo

znakki / protractor-retry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yahoo/protractor-retry

0.0 1.0 0.0 31 KB

Use protractor features to automatically re-run failed tests with a specific configurable number of attempts.

License: MIT License

JavaScript 100.00%

protractor-retry's Introduction

npm version Build Status

Protractor-retry

  • A solution to address the flakyness of your Protractor FE automation test suites.
  • This module used protractor features to automatically re-run failed tests with a specific configurable number of attempts.
  • This module is added in our CICD pipelines where we have a zero failure policy in order to bless an environment.
  • Mocha & Jasmine are supported.



This module fully relies on protractor available callbacks and internal functionalities.

It is from within protractor itself and not relying on any external dependency. All the changes that you need to add in order to integrate this module is located only in one file, the protractor configuration file. *You don’t need to update a single line of the spec.js files.

The module will create an XML file which contains the failed spec(s) filename(s). and will re-run only them, till either we don't have anymore failures or we reached the retry attempt maximum.

The process of retrying is not happening on the fly of a test failure but only after the whole testsuite is run. The failed tests are stored and only those ones are going to be rerun.



Steps to Integrate

Install

npm i -g  protractor-retry

Step 1: Require the Package ( Your Protractor Config )

var retry = require('protractor-retry').retry;

Step 2: onPrepare ( Your Protractor Config )

onPrepare: function() {
  retry.onPrepare();
}

Step 3: onCleanUp ( Your Protractor Config )

onCleanUp = function(results) {
    retry.onCleanUp(results);
};

It is Mandatory to provide the results to the retry.onCleanUp function

Step 4: afterLaunch ( Your Protractor Config )

afterLaunch = function() {
   return retry.afterLaunch(NUMBER_OF_RETRIES);
}

It is Mandatory to use return here

Full Protractor Config snippet with 2 retries

exports.config = {
    // rest of your config
    onCleanUp: function (results) {
        retry.onCleanUp(results);
    },
    onPrepare: function () {
        retry.onPrepare();
    },
    afterLaunch: function() {
        return retry.afterLaunch(2);
    }
};

Examples

Those 3 examples are actually used for the functional tests of this pkg, feel free to take a look at the Travis output to check out the flow of the retries.

Known Caveat

  • If you are NOT Running in Parallel mode, the package will retry the whole testsuite if any failure.
  • Windows as an environment to launch / use this package is not yet supported.

protractor-retry's People

Contributors

amrot17 avatar dreuxl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.