@cypress/skip-test
Advanced tools
Comparing version 2.4.1 to 2.5.0
25
index.js
@@ -60,2 +60,6 @@ /// <reference path="./index.d.ts" /> | ||
if (isHeadedName(normalizedName)) { | ||
return headedMatches(normalizedName) | ||
} | ||
if (isEnvironment(name)) { | ||
@@ -77,2 +81,14 @@ return true | ||
const isBrowser = name => ['electron', 'chrome', 'firefox'].includes(name) | ||
const isHeadedName = name => ['headed', 'headless'].includes(name) | ||
const headedMatches = name => { | ||
if (name === 'headed') { | ||
return Cypress.browser.isHeaded | ||
} | ||
if (name === 'headless') { | ||
return Cypress.browser.isHeadless | ||
} | ||
throw new Error(`Do not know how to treat headed flag "${name}"`) | ||
} | ||
/** | ||
@@ -145,2 +161,9 @@ * You can pass custom environment name when running Cypress | ||
if (isHeadedName(normalizedName)) { | ||
if (!headedMatches(normalizedName)) { | ||
return cb() | ||
} | ||
return it(`Skipping test(s) in ${normalizedName} mode`) | ||
} | ||
if (!matchesUrlPart(normalizedName)) { | ||
@@ -211,2 +234,4 @@ return cb() | ||
return cb() | ||
} else { | ||
return it(`Skipping test(s), not on ${name}`) | ||
} | ||
@@ -213,0 +238,0 @@ } else { |
{ | ||
"name": "@cypress/skip-test", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "Simple commands to skip a test based on platform, browser or an url", | ||
@@ -10,3 +10,6 @@ "main": "index.js", | ||
"semantic-release": "semantic-release", | ||
"format": "prettier --write '*.js' 'cypress/**/*.js'" | ||
"format": "prettier --write '*.js' 'cypress/**/*.js'", | ||
"e2e": "mocha --timeout 30000 test", | ||
"cy:open": "cypress open", | ||
"cy:run": "cypress run" | ||
}, | ||
@@ -22,4 +25,7 @@ "keywords": [ | ||
"cypress": "3.8.3", | ||
"debug": "4.1.1", | ||
"mocha": "7.0.1", | ||
"prettier": "1.19.1", | ||
"semantic-release": "15.14.0" | ||
"semantic-release": "15.14.0", | ||
"spok": "1.3.0" | ||
}, | ||
@@ -26,0 +32,0 @@ "repository": { |
@@ -170,2 +170,26 @@ # @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) | ||
### Headed | ||
You can skip or run tests in headed / headless environments | ||
```js | ||
import { skipOn, onlyOn } from '@cypress/skip-test' | ||
skipOn('headed', () => { | ||
it('skips the current test in headed mode', () => { | ||
cy.wrap(true).should('equal', true) | ||
}) | ||
}) | ||
onlyOn('headless', () => { | ||
it('runs only in headless mode', () => { ... }) | ||
}) | ||
``` | ||
**Note:** when skipping tests in this case, it will insert an empty placeholder test to provide information why the tests were skipped. | ||
```text | ||
- Skipping test(s), not on headed | ||
``` | ||
### `ENVIRONMENT` | ||
@@ -172,0 +196,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
15833
263
275
6