@cypress/skip-test
Advanced tools
Comparing version 1.1.0 to 1.2.0
91
index.js
@@ -36,3 +36,3 @@ /// <reference path="./index.d.ts" /> | ||
*/ | ||
export const skipOn = name => { | ||
export const skipOn = (name, cb) => { | ||
if (!_.isString(name) || '') { | ||
@@ -50,20 +50,41 @@ throw new Error( | ||
const normalizedName = normalizeName(name) | ||
cy.log(`skipOn **${normalizedName}**`) | ||
if (isPlatform(normalizedName)) { | ||
if (Cypress.platform === normalizedName) { | ||
skip() | ||
if (cb) { | ||
if (isPlatform(normalizedName)) { | ||
if (Cypress.platform !== normalizedName) { | ||
return cb() | ||
} | ||
return | ||
} | ||
return | ||
} | ||
if (isBrowser(normalizedName)) { | ||
if (Cypress.browser.name === normalizedName) { | ||
skip() | ||
if (isBrowser(normalizedName)) { | ||
if (Cypress.browser.name !== normalizedName) { | ||
return cb() | ||
} | ||
return | ||
} | ||
return | ||
} | ||
if (matchesUrlPart(normalizedName)) { | ||
return skip() | ||
if (!matchesUrlPart(normalizedName)) { | ||
return cb() | ||
} | ||
} else { | ||
cy.log(`skipOn **${normalizedName}**`) | ||
if (isPlatform(normalizedName)) { | ||
if (Cypress.platform === normalizedName) { | ||
skip() | ||
} | ||
return | ||
} | ||
if (isBrowser(normalizedName)) { | ||
if (Cypress.browser.name === normalizedName) { | ||
skip() | ||
} | ||
return | ||
} | ||
if (matchesUrlPart(normalizedName)) { | ||
return skip() | ||
} | ||
} | ||
@@ -75,3 +96,3 @@ } | ||
*/ | ||
export const onlyOn = name => { | ||
export const onlyOn = (name, cb) => { | ||
if (!_.isString(name) || '') { | ||
@@ -85,20 +106,34 @@ throw new Error( | ||
cy.log(`onlyOn **${normalizedName}**`) | ||
if (cb) { | ||
if (isPlatform(normalizedName) && Cypress.platform === normalizedName) { | ||
return cb() | ||
} | ||
if (isPlatform(normalizedName)) { | ||
if (Cypress.platform !== normalizedName) { | ||
skip() | ||
if (isBrowser(normalizedName) && Cypress.browser.name === normalizedName) { | ||
return cb() | ||
} | ||
return | ||
} | ||
if (isBrowser(normalizedName)) { | ||
if (Cypress.browser.name !== normalizedName) { | ||
skip() | ||
if (matchesUrlPart(normalizedName)) { | ||
return cb() | ||
} | ||
return | ||
} | ||
} else { | ||
cy.log(`onlyOn **${normalizedName}**`) | ||
if (!matchesUrlPart(normalizedName)) { | ||
return skip() | ||
if (isPlatform(normalizedName)) { | ||
if (Cypress.platform !== normalizedName) { | ||
skip() | ||
} | ||
return | ||
} | ||
if (isBrowser(normalizedName)) { | ||
if (Cypress.browser.name !== normalizedName) { | ||
skip() | ||
} | ||
return | ||
} | ||
if (!matchesUrlPart(normalizedName)) { | ||
return skip() | ||
} | ||
} | ||
@@ -105,0 +140,0 @@ } |
{ | ||
"name": "@cypress/skip-test", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Simple commands to skip a test based on platform, browser or an url", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -84,2 +84,20 @@ # @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) | ||
### imports with callback | ||
Instead of dynamically skipping a test at run-time, you can hide entire blocks of tests using the callback format. | ||
```js | ||
onlyOn('mac', () => { | ||
// this callback will only evaluate on Mac | ||
// thus the tests will be completely hidden from other platforms | ||
describe('Mac tests', () => { | ||
it('works', () => {}) | ||
}) | ||
}) | ||
skipOn('mac', () => { | ||
// this test will run on every platform but Mac | ||
it('hides this test on Mac', () => {}) | ||
}) | ||
``` | ||
### Notes | ||
@@ -86,0 +104,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
9242
137
157