Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
mocha-retry
Advanced tools
This is the repo for Mocha Retry project.
This Mocha plugin allows you to run a test and, if it fails, rerun it a number of times.
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.
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.
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.
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.
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.
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.
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.
FAQs
a way to retry tests
The npm package mocha-retry receives a total of 402 weekly downloads. As such, mocha-retry popularity was classified as not popular.
We found that mocha-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.