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

mocha-retry

v0.1.0

Published

a way to retry tests

Downloads

2,245

Readme

Mocha Retry

This is the repo for Mocha Retry project.

Documentation

This Mocha plugin allows you to run a test and, if it fails, rerun it a number of times.

Why you shouldn't use this

Tests that pass sometimes, and sometimes they don't are a bad smell. Your tests should be consistent: either they always pass, or they always fail. So, don't you this Mocha plugin, instead make your tests consistent.

Why you maybe want to use this

The above rule should be followed always, but sometimes you can't. Some tests are inherently incosistent, like tests that touch some type of physical artifact, like the network, files, or a web browser. Such tests may fail for reasons outside of your control. Maybe the network had a hiccup, or your web browser driver failed to communicate properly with the web browser. Who knows? If you can trace the problem and eliminate, then do that, it is the preferred option. If you can't, then you have this Mocha plugin.

Why I wrote this

The main problem I have is with end to end tests driving a web browser. I use mostly Selenium WebDriver and I have developed lots of techniques that help me work around most of the issues caused by the inherent instability of such tests, but some are just not easily fixable. This is the problem I am solving for myself.

Using it

You can specify the retry count on the test directly like this:

it 2, 'a test', ->
  #your test goes here, it will be retried at most twice

Or you can specify the retry count on the suite, like this:

describe 4, 'some suite', ->
  it 'a test', ->
    #your test goes here, it will be retried at most twice

If you specify both the test has precedence. This test will be retried at most twice, not 4 times:

describe 4, 'some suite', ->
  it 2, 'a test', ->
    #your test goes here, it will be retried at most twice

You can still use the default it behaviour, without retry, just do not specify a retry as you normally would on a Mocha test.

Installing via npm

Just run on your terminal:

npm install mocha-retry

Then you will have to change the ui, use xunit-retry as your ui. See the example here on the mocha.opts file.

Problems running it with a locally installed package

Mocha is not yet able to use a locally installed ui. I have submitted a pull request to fix that. Until then either use my version of mocha from which I did the pull request or install it globally.

Issues

Maintainers

License

This software is open source, licensed at GPL V2. Check out the terms of the license before you contribute, fork, copy or do anything with the code. If you decide to contribute you agree to grant copyright of all your contribution to this project, and agree to mention clearly if do not agree to these terms. Your work will be licensed with the project at GPL V2, along the rest of the code.