Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
How to run Cypress tests on customer project
Easy tutorial how to
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 download example tests on qa-training-logic REPO from gitLab (as a zip or clone repository for git).
Repository: https://gitlab.pricefx.eu/logic/qa-training-logic
Learn how to connect PriceFx gitLab repo with sourceTree: https://www.awordfromnet.com/access-gitlab-via-sourcetree-updated/
If you are not a friend with git and sourceTree, it is possible to download repo with tests directly as a zip file.
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