Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
minLevel1
maxLevel61
outlinefalse
stylenone
typelist
printablefalse

How to run Cypress tests on customer project

Easy tutorial how to

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

Tests

You can download obtain example tests on from the qa-training-logic REPO from gitLab (on GitLab by downloading it as a zip file or clone cloning the repository for git)Git.

Info
Repository

NOTE: The repository link is 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 unfamiliar with git Git and sourceTree, it is possible to download repo with tests directly 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 Access GitLab via SourceTree (UPDATED) - A Word From Net."

Image Modified

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

  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

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
title1. Login into gitlab and go to your project repository
Expand
title2. Create a new Branch under Dev or Master in your project
Expand
title3. 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

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

How to set up Cypress for your projects

Expand
title6. 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

Expand
title7. 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

Expand
title8. 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

Expand
title9. 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.

Expand
title10. 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

Expand
title11. 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

View file
nameexampleTestDataExtractorStructure.spec.js

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.

  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