cypress-plugin-retries
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "cypress-plugin-retries", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Cypress plugin allowing tests to retry a configurable amount of times", | ||
"main": "src", | ||
"scripts": { | ||
"test-e2e": "node test.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node test.js" | ||
}, | ||
@@ -10,0 +9,0 @@ "keywords": [ |
@@ -5,4 +5,7 @@ | ||
<img src="docs/readme-logo.png"> | ||
<h1>cypress-plugin-retries <kbd>beta</kbd></h1> | ||
<h1>cypress-plugin-retries</h1> | ||
<a href="https://www.npmjs.com/package/cypress-plugin-retries"><img src="https://img.shields.io/npm/v/cypress-plugin-retries.svg?style=flat"></a> | ||
<a href="https://www.npmjs.com/package/cypress-plugin-retries"><img src="https://img.shields.io/npm/dt/cypress-plugin-retries.svg"></a> | ||
<a href="https://github.com/bkucera/cypress-plugin-retries/blob/master/LICENSE"><img src="https://img.shields.io/github/license/bkucera/cypress-plugin-retries.svg"></a> | ||
<p>A Cypress plugin to retry failed tests</p> | ||
@@ -12,5 +15,5 @@ | ||
> :warning: this module is in beta, and might cause some strange failures. Please report bugs in the issues of this repo. | ||
> **Please report bugs in the issues of this repo.** | ||
> Note: [please refer to this issue for updates about official cypress retry support](https://github.com/cypress-io/cypress/issues/1313) | ||
> [Please refer to this issue for updates about official cypress retry support](https://github.com/cypress-io/cypress/issues/1313) | ||
@@ -35,8 +38,3 @@ ![](docs/readme-screenshot.png) | ||
**[Preferred]** On a per-test or per-hook basis, set the retry number: | ||
> Note: this plugin **adds Cypress.currentTest** and you should only use it if you're using this plugin. | ||
```js | ||
Cypress.currentTest.retries(2) | ||
``` | ||
**or** Use the environment variable `CYPRESS_RETRIES` to set the retry number for **all spec files**: | ||
Use the environment variable `CYPRESS_RETRIES` to set the retry number for **all spec files**: | ||
```bash | ||
@@ -49,2 +47,9 @@ CYPRESS_RETRIES=2 npm run cypress | ||
``` | ||
**or** On a per-test or per-hook basis, set the retry number: | ||
> Note: this plugin **adds Cypress.currentTest** and you should only access it in the context of this plugin. | ||
```js | ||
it('test', () => { | ||
Cypress.currentTest.retries(2) | ||
}) | ||
``` | ||
**or [undersirable]** Use `mocha`'s `this.retries(n)` inside of a test: | ||
@@ -58,3 +63,13 @@ > Note: **must use `function()` notation, not arrows `()=>{}`** | ||
### How it works | ||
- tests only retry on failure. If all your tests pass on the first try, it's as if you didn't have this plugin. | ||
- during a retry, all `beforeEach` and `afterEach` hooks that apply the test will be re-ran | ||
- `beforeAll(before)` hooks are not re-ran on retry. These are guaranteeed only to be ran once. | ||
- if a test fails in a `beforeEach` hook, the test will retry | ||
- if a test fails in a `afterEach`/`afterAll` hook, the test will not retry, but fail as normal | ||
- only the final run of a test will be sent to the mocha reporter/Dashboard. This means if a test passes on the second retry, you'll see one passing test. | ||
- a screenshot is taken on each test retry. This can be configured as detailed here: https://docs.cypress.io/api/commands/screenshot.html#Test-Failures | ||
- commands from past test tries will be faded out, as shown in the screenshot above | ||
### License | ||
[MIT](LICENSE) |
@@ -183,2 +183,3 @@ const _ = Cypress._ | ||
Object.defineProperty(Cypress, 'currentTest', { | ||
configurable: true, | ||
get: function(){ | ||
@@ -185,0 +186,0 @@ const r = cy.state('runnable') |
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
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
8477
173
1
71