Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

qunit-retry

TravisCI Build Status Latest NPM release

Drop in replacement for QUnit test to retry test upon failure.

// retry this test on failure as third party service occasionally fails
// we need to test against third party service
// we can live with occasional third party service failure
retry("a test relying on 3rd party service that occasionally fails", async function(assert) {
  var result = await occasionallyFailingServiceTestResult();
  assert.equal(result, 42);
});

Use very sparingly, for a suite of 2024 tests, using this for a single acceptance test.

Blog post about qunit-retry available here.

Set Max Runs

To change the number of retries, set a value in the third parameter (maxRuns). The default value for maxRuns is 2 (one attempt and one retry):

// retry this test **two times** (in addition to one initial attempt)
// on failure as third party service occasionally fails
// we need to test against third party service
// we can live with occasional third party service failure
retry("a test relying on 3rd party service that occasionally fails", async function(assert) {
  var result = await occasionallyFailingServiceTestResult();
  assert.equal(result, 42);
}, 3);

Note: It is generally advised to use the retry sparingly and this advice extends to setting a large number of retries.

Install

npm

npm install --save-dev qunit-retry

or using yarn:

yarn add --dev qunit-retry

Node

const setup = require('qunit-retry');

const retry = setup(QUnit.test);

Directly in browser

<script src="//code.jquery.com/qunit/qunit-2.9.3.js"></script>

<script type="module">
  import setup from 'https://unpkg.com/qunit-retry/main.js'

  const retry = setup(QUnit.test)

  retry("a test relying on 3rd party service that occasionally fails", async function(assert) {
    var result = await occasionallyFailingServiceTestResult();
    assert.equal(result, 42);
  });
</script>

Contributing

How to Run Tests

npm test

How to Run Linting

npm run lint

License

qunit-retry is developed by and © mrloop and contributors. It is released under the ISC License.

About

Drop in replacement for qunit `test` which retries a failed test.

Topics

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •