Skipping and Focusing Tests: skip() and only()
You'll learn how to temporarily disable or isolate tests to speed up development and debugging.
The Development Reality
When working on a large test suite, you don't always want to run every test. Maybe you're debugging one specific feature, or perhaps a test is temporarily broken due to incomplete work. Running hundreds of tests every time you make a small change wastes time and obscures the output you actually care about.
Skipping Tests with .skip()
Use .skip() to temporarily exclude tests from execution without deleting them:
describe('User authentication', () => {
it('validates correct passwords', () => {
// This runs normally
});
it.skip('handles OAuth login', () => {
// This test is skipped — won't run
// Useful when OAuth integration isn't ready yet
});
});
You can also skip entire suites:
describe.skip('Payment processing', () => {
// None of these tests will run
it('charges credit cards', () => { /* skipped */ });
it('handles refunds', () => { /* skipped */ });
});
Focusing Tests with .only()
Use .only() to run just the tests you're currently working on:
describe('Shopping cart', () => {
it.only('adds items correctly', () => {
// ONLY this test runs — all others ignored
});
it('removes items', () => {
// Skipped because .only() is used elsewhere
});
});
Warning: Never commit .only() to version control — it causes other tests to be silently ignored in CI!
Key Takeaway: Use .skip() to temporarily disable problematic tests and .only() to focus on specific tests during development, but remember to remove .only() before committing your code.