@cypress/skip-test
Advanced tools
Comparing version 1.0.0 to 1.1.0
18
index.js
@@ -33,3 +33,6 @@ /// <reference path="./index.d.ts" /> | ||
Cypress.Commands.add('skipOn', name => { | ||
/** | ||
* Skips the current test based on the browser, platform or url. | ||
*/ | ||
export const skipOn = name => { | ||
if (!_.isString(name) || '') { | ||
@@ -66,5 +69,8 @@ throw new Error( | ||
} | ||
}) | ||
} | ||
Cypress.Commands.add('onlyOn', name => { | ||
/** | ||
* Runs the current test only in the specified browser, platform or against url. | ||
*/ | ||
export const onlyOn = name => { | ||
if (!_.isString(name) || '') { | ||
@@ -97,2 +103,6 @@ throw new Error( | ||
} | ||
}) | ||
} | ||
Cypress.Commands.add('skipOn', skipOn) | ||
Cypress.Commands.add('onlyOn', onlyOn) |
{ | ||
"name": "@cypress/skip-test", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Simple commands to skip a test based on platform, browser or an url", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,4 +20,6 @@ # @cypress/skip-test [![renovate-app badge][renovate-badge]][renovate-app] [![semantic-release][semantic-image] ][semantic-url] [![CircleCI](https://circleci.com/gh/cypress-io/cypress-skip-test/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-skip-test/tree/master) | ||
Then add this module to your support file `cypress/support/index.js` | ||
## Example | ||
You can use this module as custom Cypress commands `cy.skipOn` and `cy.onlyOn` or by importing its functions. To use custom commands, add this module to your support file `cypress/support/index.js` | ||
```js | ||
@@ -27,6 +29,4 @@ require('@cypress/skip-test') | ||
## Example | ||
### `cy.skipOn` | ||
### `cy.skip` | ||
Skip this test if running in Electron browser | ||
@@ -70,2 +70,18 @@ | ||
### imports | ||
```js | ||
import { onlyOn, skipOn } from '../..' | ||
it('runs only on Mac', () => { | ||
// using the exported function instead of | ||
// the custom command cy.onlyOn(...) | ||
onlyOn('mac') | ||
}) | ||
it('skips on Mac', () => { | ||
skipOn('darwin') | ||
}) | ||
``` | ||
### Notes | ||
@@ -99,2 +115,18 @@ | ||
## Warning | ||
Skipping tests in Mocha at run-time skips the `afterEach` hooks. In this example, `afterEach` will be skipped, and `after` hook will run. | ||
```js | ||
it('example', () => { | ||
cy.skipOn('mac') | ||
}) | ||
afterEach(() => { | ||
// this will be skipped when a test is skipped | ||
}) | ||
after(() => { | ||
// this will run even after skipping test | ||
}) | ||
``` | ||
## Authors | ||
@@ -101,0 +133,0 @@ |
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
8028
107
139