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 9 Next »

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

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:

(info) 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.

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

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

(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

  1. Download Visual Studio Code or any different source code editor

  2. Open „firstTest.spec.js “ test in folder „integration“ (this is folder, where tests are placed)

  3. 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

  4. 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

PROS

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.

 1. Login into gitlab and go to your project repository
 2. Create a new Branch under Dev or Master in your project
 3. Set up the cypress first in your local and later could be pushed into git
  1. Clone the cypress folder from the repository

https://gitlab.pricefx.eu/logic/qa-training-logic into your local

 5. Visual Studio Code editor is used to write and run the tests locally first.

How to set up Cypress for your projects

 6. To get started, these files need to be updated
  • cypress.json

  • fixtures/testUsersUtils.js

  • delete last row in support/index.js (if needed only)

  • delete import 'cypress-file-upload'; from support/commands.js

 7. Create a new test with just login and check if it works and you are able to login to the required partition. Run (npx cypress open) command from the terminal

 8. Push the cypress folder and the other updated config files cypress.json, package.json and .gitlab-ci.yml into the new Branch created in git repo

 9. Make sure Gitlab CI/CD pipeline is enabled in your project.
  • On the top bar, select Menu > Projects and find your project.

  • On the left sidebar, select Settings > General.

  • Expand Visibility, project features, permissions.

  • In the Repository section, turn on or off CI/CD as required.

 10. Add new variables to hold username, password and partition details.

As its not secure to store the credentials in the code and connect these variables in gitlab to testUserUtils file

 11. Create a new pipeline and you can ‘Run pipeline’ whenever needed.

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

(info) link: https://developer.pricefx.eu/tools/test-extractor/#

Example file for using data extractor tool

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 use IntelliJ 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.

  1. Manualy create LPG or PL which you want to test (with elements and products which you want to test)

  2. Open https://developer.pricefx.eu/tools/test-extractor/#

  3. Log in and choose your LPG or PL

  4. Click on „Run Logic“ button

  5. Go to „JSON“ and save your new generated json into same folder as our tests

  6. Go to „Cypress“ in test data extractor

  7. Copy code into PL or LPG cypress test

  8. Run cypress test

  • No labels