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.2.0 to 2.3.0

14

index.js

@@ -50,5 +50,10 @@ /// <reference path="./index.d.ts" />

if (isEnvironment(name)) {
return true
}
return matchesUrlPart(normalizedName)
}
// @ts-ignore "cy.state" is not in the "cy" type
const getMochaContext = () => cy.state('runnable').ctx

@@ -62,2 +67,11 @@ const skip = () => {

const isBrowser = name => ['electron', 'chrome', 'firefox'].includes(name)
/**
* You can pass custom environment name when running Cypress
* @example
* CYPRESS_ENVIRONMENT=staging npx cypress run
* @param {string} name Is checked against `ENVIRONMENT` value
* @returns {boolean} true if the given argument matches environment string
*/
const isEnvironment = name =>
Cypress.env('ENVIRONMENT') && Cypress.env('ENVIRONMENT') === name

@@ -64,0 +78,0 @@ const matchesUrlPart = normalizedName => {

10

package.json
{
"name": "@cypress/skip-test",
"version": "2.2.0",
"version": "2.3.0",
"description": "Simple commands to skip a test based on platform, browser or an url",

@@ -9,3 +9,4 @@ "main": "index.js",

"test": "cypress run",
"semantic-release": "semantic-release"
"semantic-release": "semantic-release",
"format": "prettier --write '*.js' 'cypress/**/*.js'"
},

@@ -20,4 +21,5 @@ "keywords": [

"devDependencies": {
"cypress": "3.6.0",
"semantic-release": "^15.13.30"
"cypress": "3.6.1",
"prettier": "1.19.1",
"semantic-release": "15.13.30"
},

@@ -24,0 +26,0 @@ "repository": {

31

README.md
# @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)
> Simple commands to skip a test based on platform, browser or an url

@@ -140,3 +141,3 @@

```js
it.only('runs if task returns production', () => {
it('runs if task returns production', () => {
cy.task('getDbName').then(name => cy.onlyOn(name === 'production'))

@@ -157,3 +158,3 @@ // equivalent

```js
import {isOn} from '@cypress/skip-test'
import { isOn } from '@cypress/skip-test'
it('loads users', () => {

@@ -171,2 +172,28 @@ // when running on Windows locally, the backend is not running

### `ENVIRONMENT`
This module also reads special environment variable `ENVIRONMENT` inside its checks. For example, to only stub network calls on `staging` environment, execute the tests like this:
```shell
CYPRESS_ENVIRONMENT=staging npx cypress run
```
Inside the spec file you can write
```js
import {onlyOn} from '@cypress/skip-test'
const stubServer = () => {
cy.server()
cy.route('/api/me', 'fx:me.json')
cy.route('/api/permissions', 'fx:permissions.json')
// Lots of fixtures ...
}
it('works', () => {
onlyOn('staging', stubServer)
...
})
```
The test `works` will stub network calls when running on `staging`, but will skip calling `stubServer` for other environments.
### Notes

@@ -173,0 +200,0 @@

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