Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@cypress/skip-test
Advanced tools
Simple commands to skip a test based on platform, browser or an url
it('skips this test when running on Mac', () => {
cy.log('about to run custom command to skip this test')
.wait(1000)
.skipOn('mac')
})
npm install -D @cypress/skip-test
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
require('@cypress/skip-test')
cy.skipOn
Skip this test if running in Electron browser
it('only runs on Electron', () => {
cy.skipOn('electron')
// the rest of the test
})
Skip this test if running on Windows platform
it('runs on Linux and Mac', () => {
cy.skipOn('windows')
// the rest of the test
})
cy.onlyOn
Continues the test only when running on Mac, skips when running on any other platform
it('runs on Mac only', () => {
cy.onlyOn('mac')
// the rest of the test
})
Continues this test only when running against localhost
. Use baseUrl
to set the url to compare.
it('only tests localhost', () => {
cy.onlyOn('localhost')
// the rest of the test
})
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')
})
You can chain conditions together
it('combination of skip and only', () => {
cy.skipOn('firefox')
cy.onlyOn('electron').onlyOn('mac')
cy.log('running test')
})
If the test runs, it will print the conditions in the command log
To get typings, reference this module, for example by using reference
comment
/// <reference types="@cypress/skip-test" />
For more details read Cypress Intelligent Completion Guide
Skipping tests in Mocha at run-time skips the afterEach
hooks. In this example, afterEach
will be skipped, and after
hook will run.
it('example', () => {
cy.skipOn('mac')
})
afterEach(() => {
// this will be skipped when a test is skipped
})
after(() => {
// this will run even after skipping test
})
FAQs
Simple commands to skip a test based on platform, browser or an url
The npm package @cypress/skip-test receives a total of 148,419 weekly downloads. As such, @cypress/skip-test popularity was classified as popular.
We found that @cypress/skip-test demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.