Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

This article provides a step-by-step guide to getting started with Cypress, a popular testing framework. It covers installation, running Cypress, building tests, and running tests. It also mentions the importance of checking the official documentation and provides links for further reference.

Learn About Cypress

Cypress is a modern test automation tool used for testing web applications. It is known for its fast, reliable, and easy-to-use features, making it popular among developers and QA professionals. Here's a summary of Cypress test automation tool:

  • Fast and Reliable: Cypress is designed for speed and reliability, providing fast test execution and consistent results, which makes it suitable for both small and large-scale test suites.

  • Easy Setup: Cypress has a straightforward setup process, allowing users to start writing and running tests quickly without the need for additional dependencies.

  • JavaScript-based: Cypress test scripts are written in JavaScript, which is widely used and familiar to many developers, making it accessible for those with JavaScript knowledge.

  • Interactive Test Runner: Cypress provides an interactive test runner that allows users to see the application under test while the tests are running, making it easier to debug and troubleshoot issues.

  • Real-time Reloads: With real-time reloads, Cypress automatically reloads the application when changes are made, providing instant feedback during the development and testing process.

  • Time Traveling Debugging: Cypress offers time-traveling debugging, allowing users to see exactly what happened at each step of the test, making it easier to diagnose failures.

  • Cross-browser Testing: Cypress supports cross-browser testing, allowing users to run tests across different browsers to ensure consistent behavior.

  • Built-in Assertions and Spies: Cypress comes with built-in assertions and spies that simplify the process of writing test assertions and interacting with the application under test.

  • Community Support: Cypress has a strong community with active support forums, documentation, and plugins, making it easy to find resources and solutions to common testing challenges.

Overall, Cypress is a powerful and user-friendly test automation tool that provides an intuitive testing experience for web applications, enabling developers and QA professionals to create and maintain reliable test suites with ease.

LEARN MORE: Before starting with useful tips and comments is highly recommended that you always check the official documentation on Cypress

Getting started

Installing

(if you don’t have initiated the project) Open your folder on VSCode, open the terminal, and type

npm init --y or yarn init (it depends on which package manager you’re using)

  1. Npm

    1. Open your folder on VSCode, open the terminal, and type npm i cypress --save-dev to install cypress as dev dependencies

b. Yarn

i. Open your folder on VSCode, open the terminal, and type yarn add cypress --dev to install cypress as dev dependencies

c. After initializing and installing the cypress you should check and confirm that the cypress is on dependencies and it’s on the version that you want

Running Cypress

a. Npm

i. Open the terminal and type npx cypress open

b. Yarn

i. Open the terminal and type yarn cypress open

3 After this you should be able to see that folders and files were created

a. cypress.json

i. Here you’ll change configurations regarding cypress, for example:

Environment base url

Height and width of viewport

b. Integration folder

i. Here you’ll create the file where your code will be written, to run it on cypress, the file's name must finish with .spec.js

c. Support folder

i. Here you should see the commands.js file that you will create customized methods

{

The commands.js should always have all the most common and used methods in terms of avoiding repetitive code, this way you write once and use the methods whenever needed without having to write it again

For example: assert text, is a simple method, but writing it several times is not a good coding practice, so for that, you could write it on commands.js and call the method when it’s needed

Remember that you can read the official documentation to study what’s the best approach to code your methods

You can find the documentation here.

Building your tests

  1. Create your spec.js file with an intuitive name for the task

Running your tests

  1. If you don’t have opened cypress

i. open the terminal on VSCode

ii. type npx cypress open or yarn cypress open (it depends on which package manager you are using)

iii. this tab will open

iv. just click on the spec file that you want to run

  • No labels