The article provides information on how to run Cypress tests on a customer project. It covers topics such as installing Cypress, downloading example tests and libraries, setting up Cypress for projects, and using a data extractor tool for testing data in Live Price Grid (LPG) or Price Lists (PL). It also discusses the benefits of automation testing and introduces Cypress as a JavaScript-based end-to-end testing framework.
The advantages of automation testing with Cypress include:
End-to-end automated front-end tests
Reduced time spent on regression testing
Increased software application quality
Elimination of manual tasks
Increased user confidence with the solution
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Cypress Testing Tutorial
Provides a comprehensive tutorial on running Cypress tests for a customer project. It covers topics such as automation testing, installing Cypress, setting up Cypress for projects, using a data extractor tool, and the benefits of automation testing. This tutorial will illustrate how to perform the following:
Download and install Cypress on your computer (3 clicks)
Download example tests and library (2 clicks)
Run your first test on you project (Change in 2 files)
Automation testing - Tutorial
There is an array of benefits to automation testing, but it is important to understand that there might also be some limitations which we will tackle on later. For the moment though, we will look at the advantages it presents:
End to end automated front-end tests for PriceFx‘s solutions
Reduced time spent on regression testing
Increased software application quality
Elimination of manual tasks
Increased user confidence with the solution
Testing approach with easy to understand automated tests for non-technical people
Cypress
Cypress is a JavaScript-based end-to-end testing framework that makes writing and maintaining tests easy. It's also great because it can be implemented into PriceFx gitLab CI/CD jobs, which makes the testing process even smoother.
With Cypress, you have the ability to write tests that everyone can understand, which is incredibly helpful for ensuring that everyone on your team is on the same page.
You can try your Cypress tests onto your allocated partition using the following information:
Link: https://demo-eu.demo1.pricefx.com/app/
username: 'cypress.io',
partition: 'qa-training',
password: 'cypress'
Example Tests
You can obtain example tests from the qa-training-logic REPO on GitLab by downloading it as a zip file or cloning the repository for Git.
Info |
---|
NOTE: The repository link is https://gitlab.pricefx.eu/logic/qa-training-logic. |
If you are unfamiliar with Git and SourceTree, you can directly download the test repository as a zip file. Additionally, you can learn how to connect the PriceFx GitLab repo with SourceTree by referring to the guide How to set up Git
To install Cypress the easy way, there are a few steps that you can take.
Go to http://cypress.io web site
Click on download now (you can download anywhere you want in your computer
Unzip your downloaded cypress version
Open cypress.exe (on windows or app on mac)
Click on select manualy and select your downloaded repo root folder
Info |
---|
Only tests in the folder “final“ should work other tests are for inspiration. |
Run Cypress via command line (optional)
Run command in root folder of downloaded repo
yarn install or npx yarn install
In root folder run this command:
node_modules\.bin\cypress run --spec "cypress/integration/final/*" --headless --browser chrome
Info |
---|
(if it is not working, you need to run: npm install cypress). |
Better in different folder than in downloaded repo
How to create the first test
Download Visual Studio Code or any different source code editor
Open „firstTest.spec.js “ test in folder „integration“ (this is folder, where tests are placed)
Now you can see empty Cypress test – your code is written in „it“ place (if you want only one test you can delete space for second test
Now you can write tests
To use the library of commands you need to know that they are place in the folder called cypress/support. The reason why you want to use this is because the test creation is faster. The code is in one place so it is easier to maintain. Moreover the test are easy to read.
Tests using library of commands
How to run it on your test
Tip |
---|
PROS |
Warning |
---|
CONS |
E2E tests
Reduced time in regression testing
Elimination of manual tasks
Increased user confidence with the solution
Ease of use for non-technical people
Only on UNITY
Front end tests could be a little fragile
Maintenance of the tests
QA person is still needed on the project
How to set up Cypress for your projects
Check out a steep by step tutorial here. Alternatively, you can download a word version of it in the downloads section, here.
Expand | ||
---|---|---|
| ||
Expand | ||
---|---|---|
| ||
Expand | ||
---|---|---|
| ||
https://gitlab.pricefx.eu/logic/qa-training-logic into your local |
Expand | ||
---|---|---|
| ||
How to set up Cypress for your projects |
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
Expand | ||
---|---|---|
| ||
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
As its not secure to store the credentials in the code and connect these variables in gitlab to testUserUtils file |
Expand | ||
---|---|---|
| ||
Or a job could be scheduled to run your tests at regular intervals. |
How to use data extractor tool
for fast LPG and PL testing
link: https://developer.pricefx.eu/tools/test-extractor/#
Example file for using data extractor tool
View file | ||
---|---|---|
|
The data extractor tool can be used for fast testing of data in LPG (Live Price grid) or PL (Price Lists). The data extractor tool can be used for creation of JSON file and commands for Cypress.
To use the data extractor tool, deploy logic into your project https://gitlab.pricefx.eu/accelerators/qa-utils/-/tree/master/. To use the data extractor tool, you can also useIntelliJ IDEA with PFX studio add-on.
A precondition to using the data extractor tool is to have downloaded cypress with latest version of library, imported logic into your partition.
Manualy create LPG or PL which you want to test (with elements and products which you want to test)
Log in and choose your LPG or PL
Click on „Run Logic“ button
Go to „JSON“ and save your new generated json into same folder as our tests
Go to „Cypress“ in test data extractor
Copy code into PL or LPG cypress test
Run cypress test