Testing

Cypress – Everything you need (1/5)

Setting up a test environment is always a hectic task. Usually QA professionals spend at least an hour to even a day to Installing all required frameworks, dependencies and configure the same to start writing the tests. By considering those pain points, Cypress built a new architecture from the ground up which bundles all required frameworks, libraries and dependencies into one package. We have written an introductory blog on Cypress  and in this blog, we’ll be giving you detailed instructions to get started using Cypress.

Getting Started

Before getting started, let’s see what are the core components needed to implement a test automation for a project.

Source : cypress.io

Adding more…

  • Allow plugins
  • Custom commands
  • Dashboard to monitor
  • CI/CD Integration
  • Cross browser support

If I say all these can be set in place by just one line command, will you believe? Yes, that’s why I’m becoming a fan of Cypress. All you need is to have NodeJS in your system. You can check the system requirements here.

$ npm install cypress –save-dev

This will install Cypress locally as a dev dependency for your project. Make sure that you have already run npm init or have a “node_modules” folder or “package.json” file in the root of your project to ensure cypress is installed in the correct directory.

$ node_modules/.bin/cypress open

This will open Cypress Test runner. Also all the required files and folders will be created automatically, which are required for the test. Also includes the example test scripts for all possible scenarios.

That’s it! Now everything is set to start writing the test.

Test Automation Frameworkhttp://mochajs.org/
Assertion Libraryhttp://chaijs.com/
Test RunnerBuild-in Test Runner
Report BuilderMocha’s built-in reporters
DebuggerBuild-in Debugger

Test Runner

An unique and significant feature of cypress is the test runner. Test runner provides an interactive interface where we can see the commands as they execute and also preview the application under test.

The most important part of the test runner is the command log. We spend most of the time in this command log which is present at the left hand side of the test runner which is a visual representation of your test suite. This command log includes each command, assertions and errors. On hover over any command will restore the Application Under Test (right hand side) to the state it was in when that command executed. Also we can see extra information in the developer tools console.

Report Builder

Since Cypress built on top of Mocha, any reporter built for Mocha can be used with Cypress. By default, you can see the test result in the terminal when run the cypress test using the below command:

$ cypress run – -record

Once the test finished, you can see the test result as below. The option  – -record  enables to record the test execution. You can find the recorded video under folder “videos”. The test result includes the list of tests along with the duration of each. The summary shows the no. of the Pass, failed, skipped and Pending of each suite.

Conclusion

Now our test environment is ready to start building the test. In our next post we will be discussing more and more about the Cypress in detail. We’ll be discussing more features about Cypress.io, in future. 

Do you like to discuss your software testing strategy with our experts?

Talk to our experts now and let us be your innovation partner!

Check out our success stories to know more about it.