Socket
Socket
Sign inDemoInstall

@cypress/skip-test

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cypress/skip-test - npm Package Compare versions

Comparing version 2.5.1 to 2.6.0

33

index.js

@@ -6,3 +6,3 @@ /// <reference path="./index.d.ts" />

const checkBrowserName = name => {
const checkBrowserName = (name) => {
if ('isBrowser' in Cypress) {

@@ -27,3 +27,3 @@ // use the new v4.0 method

*/
const normalizeName = name => {
const normalizeName = (name) => {
name = name.toLowerCase()

@@ -47,3 +47,3 @@

*/
const isOn = name => {
const isOn = (name) => {
if (!_.isString(name)) {

@@ -81,7 +81,9 @@ throw new Error('Invalid syntax: isOn expects a string argument')

const isPlatform = name => ['win32', 'darwin', 'linux'].includes(name)
const isBrowser = name => ['electron', 'chrome', 'firefox'].includes(name)
const isHeadedName = name => ['headed', 'headless'].includes(name)
const isPlatform = (name) => ['win32', 'darwin', 'linux'].includes(name)
const isBrowser = (name) => ['electron', 'chrome', 'firefox'].includes(name)
const isHeadedName = (name) => ['headed', 'headless'].includes(name)
const isEnvironmentSet = () =>
typeof Cypress.env('ENVIRONMENT') === 'string' && Cypress.env('ENVIRONMENT')
const headedMatches = name => {
const headedMatches = (name) => {
if (name === 'headed') {

@@ -103,6 +105,6 @@ return Cypress.browser.isHeaded

*/
const isEnvironment = name =>
const isEnvironment = (name) =>
Cypress.env('ENVIRONMENT') && Cypress.env('ENVIRONMENT') === name
const matchesUrlPart = normalizedName => {
const matchesUrlPart = (normalizedName) => {
// assuming name is part of the url, and the baseUrl should be set

@@ -171,2 +173,9 @@ const url = Cypress.config('baseUrl') || location.origin

if (isEnvironmentSet()) {
if (!isEnvironment(normalizedName)) {
return cb()
}
return it(`Skipping test(s) on ${normalizedName} environment`)
}
if (!matchesUrlPart(normalizedName)) {

@@ -192,2 +201,8 @@ return cb()

if (isEnvironmentSet()) {
if (isEnvironment(normalizedName)) {
return skip()
}
}
if (matchesUrlPart(normalizedName)) {

@@ -194,0 +209,0 @@ return skip()

{
"name": "@cypress/skip-test",
"version": "2.5.1",
"version": "2.6.0",
"description": "Simple commands to skip a test based on platform, browser or an url",

@@ -23,7 +23,7 @@ "main": "index.js",

"devDependencies": {
"cypress": "5.6.0",
"cypress": "6.2.0",
"debug": "4.3.1",
"mocha": "8.2.1",
"prettier": "2.1.2",
"semantic-release": "15.14.0",
"prettier": "2.2.1",
"semantic-release": "17.3.1",
"spok": "1.3.0"

@@ -30,0 +30,0 @@ },

@@ -153,8 +153,8 @@ # @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)

it('runs if task returns production', () => {
cy.task('getDbName').then(name => cy.onlyOn(name === 'production'))
cy.task('getDbName').then((name) => cy.onlyOn(name === 'production'))
// equivalent
cy.task('getDbName').then(name => onlyOn(name === 'production'))
cy.task('getDbName').then((name) => onlyOn(name === 'production'))
// equivalent
cy.task('getDbName')
.then(name => name === 'production')
.then((name) => name === 'production')
.then(onlyOn)

@@ -217,3 +217,3 @@ })

```js
import {onlyOn} from '@cypress/skip-test'
import {onlyOn, skipOn} from '@cypress/skip-test'
const stubServer = () => {

@@ -229,5 +229,8 @@ cy.server()

})
skipOn('staging', () => {
it('works on non-staging', () => {...})
})
```
The test `works` will stub network calls when running on `staging`, but will skip calling `stubServer` for other environments.
The test `works` will stub network calls when running on `staging`, but will skip calling `stubServer` for other environments. The test `works on non-staging` will be skipped when the environment is `staging`.

@@ -234,0 +237,0 @@ ### Notes

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc