How to Skip Tests in Cypress: Simple Guide
In Cypress, you can skip a test by adding
.skip to the test or test suite function, like it.skip() or describe.skip(). This tells Cypress to ignore that test or group of tests during execution without deleting the code.Syntax
Use it.skip() to skip a single test and describe.skip() to skip a whole test suite. This prevents Cypress from running those tests but keeps them in your code for later use.
it.skip('test name', () => { ... }): skips one testdescribe.skip('suite name', () => { ... }): skips all tests in the suite
javascript
describe.skip('Skipped Test Suite', () => { it('This test will be skipped', () => { // test code here }) }) it.skip('This single test is skipped', () => { // test code here })
Output
Tests marked with .skip are not executed and show as skipped in Cypress test runner.
Example
This example shows a test suite with one skipped test and one normal test. The skipped test will not run or affect the test results.
javascript
describe('My Test Suite', () => { it.skip('Skipped test', () => { cy.visit('https://example.com') cy.get('h1').should('contain.text', 'Example Domain') }) it('Runs normally', () => { cy.visit('https://example.com') cy.get('h1').should('be.visible') }) })
Output
The test runner shows 'Skipped test' as skipped and only runs 'Runs normally' test which passes.
Common Pitfalls
Common mistakes when skipping tests include:
- Forgetting to remove
.skipand missing important tests. - Using
xitorxdescribe(legacy aliases) which still work but are less clear than.skip. - Skipping tests unintentionally by placing
.skipon the wrong test or suite.
Always double-check skipped tests before final test runs.
javascript
/* Wrong: accidentally skipping all tests */ describe.skip('My Suite', () => { it('Test 1', () => { // This test will be skipped unintentionally }) }) /* Right: skip only one test */ describe('My Suite', () => { it.skip('Skip this test only', () => { // skipped }) it('Run this test', () => { // runs normally }) })
Output
In the wrong example, all tests are skipped; in the right example, only one test is skipped.
Quick Reference
| Command | Effect |
|---|---|
| it.skip('test name', () => {...}) | Skip a single test |
| describe.skip('suite name', () => {...}) | Skip an entire test suite |
| xit('test name', () => {...}) | Legacy: skip a single test |
| xdescribe('suite name', () => {...}) | Legacy: skip a test suite |
Key Takeaways
Use
it.skip() to skip individual tests without deleting them.Use
describe.skip() to skip entire test suites temporarily.Check skipped tests before final runs to avoid missing important tests.
Avoid legacy
xit and xdescribe in new code; prefer .skip.Skipped tests appear clearly in Cypress test runner as skipped, not failed.