0
0
Cypresstesting~3 mins

Why Skipping and focusing tests (.skip, .only) in Cypress? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could instantly zoom in on just the tests that matter right now?

The Scenario

Imagine you have a big list of tests to run every day. You want to check just one or two tests quickly, but you have to wait for all tests to finish before seeing results.

The Problem

Running all tests every time is slow and tiring. You might miss important problems because you get overwhelmed. Also, manually ignoring tests by commenting them out can cause mistakes and forgetfulness.

The Solution

Using .skip and .only lets you tell Cypress exactly which tests to ignore or focus on. This saves time and helps you find problems faster without changing your code a lot.

Before vs After
Before
/* Comment out tests manually */
// it('test A', () => {...})
it('test B', () => {...})
After
it.skip('test A', () => {...})
it.only('test B', () => {...})
What It Enables

You can quickly run just the tests you care about, making debugging and development faster and less frustrating.

Real Life Example

When fixing a bug, you can focus only on the related test with .only, skipping all others, so you get instant feedback on your fix.

Key Takeaways

Running all tests every time is slow and error-prone.

.skip and .only let you control which tests run.

This makes testing faster and easier to manage.