trytryagain
Keep trying until it works. Actually a very reliable testing strategy.
Last updated 5 years ago by refractalize .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install trytryagain 
SYNC missed versions from official npm registry.

If at first you don't succeed, try try again

if at first you don't succeed, try try again

Retrying assertions is a very reliable strategy for testing applications, whether you're testing in the browser, on mobile, or testing networked applications. Anywhere timing is variable.

var retry = require('trytryagain');

describe('my application', function () {
  it('has the right title', function () {

    return retry(function () {

      return browser.title().then(function (title) {
        return expect(title).to.equal('My App');
      });

    });

  });
});

NPM: trytryagain

npm install trytryagain

retry

var promise = retry(function, [options]);
var promise = retry([options], function);
  • function is a function that will be called repeatedly until it doesn't throw an exception, or return a promise that is rejected.
  • options.timeout millisecond to retry until giving up. default 1000.
  • options.interval retry interval in milliseconds. default 10.

Returns a promise. If the function eventually returns a value then this promise will be fulfilled with that value. If the function continually throws or rejects, then this function will be rejected with the error.

retry.ensuring

retry.ensuring is kind of the oppposite of retry, it keeps trying the assertion as long as it doesn't fail, and fails immediately if it fails. This is useful in situation where you want to ensure that something doesn't happen, but you want to check long enough to be sure.

var promise = retry.ensuring(function, [options]);
var promise = retry.ensuring([options], function);
  • function is a function that will be called repeatedly until it does throw an exception, or until duration milliseconds has passed.
  • options.duration milliseconds to retry before declaring success. default 1000.
  • options.interval retry interval in milliseconds. default 10.

Current Tags

  • 1.2.0                                ...           latest (5 years ago)

5 Versions

  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |