Cypress Quick Tip: Skip and Only

03/04/20181 Min Read — In Resources, Testing, Development

In your day to day use of Cypress, especially using it for day to day development, you will want to focus on your signal from the noise that a constant testrunner can evoke.

Only the Lonely

When you are developing a feature or working on a specific test, you can run your single .spec.js file and then further focus by adding a .only to your it or specify. This allows you to hyperfocus on your task, which means you should probably be using them all the time. You can also use this for your context or describe and the nested tests will be ran.

it.only('User can not see this, () => {

I haven't yet figured out a linter setting to keep from accidentally committing these but I know it will happen one day. Watch out for this!

Skip It

Another thing I like to do is use .skip for context or describe in a whole spec file. I use this because I like to scaffold out future tests. It can function like a TODO: in that case. Or even be used like in a BDD setup.

describe.skip('Smoke Test Error Page', () => {
beforeEach(() => {
it.only('Check error text displays', () => {

Skips are especially handy if multiple folks are going to be contributing to your integration tests. You might have a dev writing basic workflows to prove their work and then the tester iterating off that work. Or the tester writes out tests that should pass and then they or someone else builds those tests out.