SDET Unicorns

Write your first test in Cypress

Write Test in Cypress

Table of Content

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

describe('Home Tests', () => {
    it('open the home page and verify the url & title', () => {
        // open the Home Page

        // assert the url
        cy.url().should("include", "automationbro");

        // assert the title
        cy.title().should("eq", "Practice E-Commerce Site – Automation Bro");
  • 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 open 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 –

I hope this post helped you out, let me know if you have any questions in the comments below!

Happy testing! 

My Resources

Thrive Suite: The all-in-one WordPress theme I used to create my blog.
Jasper AI: My favorite AI writing tool.
Surfer SEO:  A tool to help you rank your content on the first page of Google.

Write Content Faster


Write blog posts that rank for affiliate terms!

Join our mailing list

Unlock the Secrets to Becoming a SDET Pro in the Industry!

Stay ahead of the curve! Join our mailing list for exclusive insights, tips, and the latest industry updates delivered straight to your inbox

Table of Content

Related Post

7 Principles of Software Testing

7 Principles of Software Testing with Examples

Software testing plays a crucial role in the software development life cycle as it helps ensure the quality, reliability, and performance of the final product. Software testing is not just about finding defects; it also provides valuable insights into the overall quality of the software. By conducting effective software testing, it shows how well the application behaves in different scenarios and whether it meets user expectations.

Read More »
Differences Between CI/CD and DevOps

Key Differences Between CI/CD and DevOps

Software development is far from a simple journey that involves merely executing code and launching applications. It often presents challenges, as it’s rare to get everything right from the start. Each time you implement new or frequent code changes, you inadvertently introduce potential issues that can be time-consuming to resolve. This complexity necessitates a structured approach to ensure smooth production.

Read More »