DEV Community

Cover image for Write your first test in Cypress
Dilpreet Johal
Dilpreet Johal

Posted on

5 3

Write your first test in Cypress

In this tutorial, we will cover how to write your first test in Cypress. We will go over the basic Cypress syntax and run our tests using the Cypress Test Runner.

Creating your Cypress Test

Cypress Test

  • to go to any URL, you can use the cy.visit() command
  • Cypress also provides various types of page assertions such as cy.url() and cy.title() to assert the URL as well as the title of the page

Running your Cypress Test in the Cypress Test Runner

To open the Cypress Test Runner, you can execute the following command below:

npx cypress open

Once the Cypress Test Runner opens up, you can execute your test which will show results similar to this below:

  • You can see all the Cypress commands listed below such as visit, URL & title
  • All your successful assertions will show in Green and failed assertions in Red

Cypress Test Runner


Check out the video below to see how to create your first test in Cypress:


📧 Subscribe to my mailing list to get access to more content like this

đź‘Ť Follow automationbro on Twitter for the latest updates

...

I love coffees! And, if this post helped you out and you would like to support my work, you can do that by clicking on the button below and buying me a cup of coffee -

Buy me a coffee

You can also support me by liking and sharing this content.

Thanks for reading!

Image of Quadratic

AI, code, and data connections in a familiar spreadsheet UI

Simplify data analysis by connecting directly to your database or API, writing code, and using the latest LLMs.

Try Quadratic free

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

đź‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay