retry-limiter
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -15,3 +15,4 @@ 'use strict'; | ||
const configDecorator = ConfigDecorator.create(gemini.config); | ||
const retryRuleAfterLimit = (data) => typeof data.equal === 'undefined' && data.retriesLeft > 0; | ||
const configDecorator = ConfigDecorator.create(gemini.config, retryRuleAfterLimit); | ||
@@ -23,3 +24,10 @@ let retryLimiter; | ||
}); | ||
gemini.on(gemini.events.RETRY, () => retryLimiter.exceedLimit() && configDecorator.disableRetries()); | ||
gemini.on(gemini.events.RETRY, function retryCallback() { | ||
if (!retryLimiter.exceedLimit()) { | ||
return; | ||
} | ||
configDecorator.disableRetries(); | ||
gemini.removeListener(gemini.events.RETRY, retryCallback); | ||
}); | ||
}; | ||
@@ -26,0 +34,0 @@ |
@@ -14,3 +14,4 @@ 'use strict'; | ||
const configDecorator = ConfigDecorator.create(hermione.config); | ||
const retryRuleAfterLimit = () => false; | ||
const configDecorator = ConfigDecorator.create(hermione.config, retryRuleAfterLimit); | ||
@@ -31,3 +32,10 @@ let retryLimiter; | ||
}); | ||
hermione.on(hermione.events.RETRY, () => retryLimiter.exceedLimit() && configDecorator.disableRetries()); | ||
hermione.on(hermione.events.RETRY, function retryCallback() { | ||
if (!retryLimiter.exceedLimit()) { | ||
return; | ||
} | ||
configDecorator.disableRetries(); | ||
hermione.removeListener(hermione.events.RETRY, retryCallback); | ||
}); | ||
}; |
'use strict'; | ||
module.exports = class ConfigDecorator { | ||
static create(config) { | ||
return new ConfigDecorator(config); | ||
static create(config, retryRule) { | ||
return new ConfigDecorator(config, retryRule); | ||
} | ||
constructor(config) { | ||
constructor(config, retryRule) { | ||
this._config = config; | ||
this._retryRule = retryRule; | ||
} | ||
@@ -14,5 +15,5 @@ | ||
this._config.getBrowserIds().forEach((browserId) => { | ||
this._config.forBrowser(browserId).retry = 0; | ||
this._config.forBrowser(browserId).shouldRetry = this._retryRule; | ||
}); | ||
} | ||
}; |
{ | ||
"name": "retry-limiter", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Plugin for gemini and hermione to disable retries at runtime", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,2 +5,10 @@ # retry-limiter [![Build Status](https://travis-ci.org/gemini-testing/retry-limiter.svg?branch=master)](https://travis-ci.org/gemini-testing/retry-limiter) | ||
## How it works? | ||
Plugin sets retries threshold. If it’s exceeded test will or will not be retried based on the result of `shouldRetry` function in config. | ||
For Gemini the rule is: if the test ends without result (nor `equal:false` nor `equal:true`) test will be retried if it’s attempts not exceeded. | ||
For Hermione the rule is: no retries. | ||
## Install | ||
@@ -14,3 +22,3 @@ | ||
### configuration | ||
### Configuration | ||
@@ -20,3 +28,3 @@ * **enabled** (optional) `Boolean` – enable/disable the plugin; default `true`. | ||
### gemini | ||
### Gemini | ||
@@ -37,3 +45,3 @@ Add the plugin to your configuration file: | ||
### hermione | ||
### Hermione | ||
@@ -40,0 +48,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7994
121
53