# Cypress Usage and Configuration

## **Cypress Coverage on Testing**

Software testing encompasses various levels to thoroughly inspect the product from different perspectives, increasing the likelihood of detecting defects. While end-to-end testing is crucial, it only addresses a single layer of testing and typically detects less than 10% of errors within a product. However, this approach has been selected to automate user experiences within processes and identify potential failures that could disrupt the process flow.

<figure><img src="https://lh7-us.googleusercontent.com/T5FAoaAo6rg1oMAM73ZdadGC77Yv2_m82I8rmNdERFn1HA5Opl5tQFfe7_gnXFmf8lVHpwTXcCaMrU3azooX-yTGzZYptuaAN_RXWM2is_KGV5fCPJtzqcaQ4-8c46hRGqsM9kQmczFaGoaq6JRzZw" alt=""><figcaption></figcaption></figure>

## **Project Configuration Options**

The `package.json` file within the project facilitates the installation of all necessary packages and dependencies for automation. Below is a sample configuration:

{% tabs %}
{% tab title="JSON" %}
{% code lineNumbers="true" %}
```json
{
  "name": "qa_ps",
  "version": "1.0.0",
  "description": "QA automation",
  "main": "index.js",
  "scripts": {
    "cypress:open": "cypress open",
    "cypress:run": "cypress run --browser chrome",
    "generate:report": "npx mochawesome-merge 'cypress/results/*.json' > mochawesome.json && npx marge mochawesome.json",
    "cypress:run:report": "cypress run --browser chrome --config-file cypress.config.js && npx mochawesome-merge 'cypress/results/*.json' > mochawesome.json && npx marge mochawesome.json",
    "delete:reports": "rm -rd cypress/results/* || true && rm mochawesome.json && rm -rd mochawesome-report",
    "complete:execution": "npm run delete:reports && npm run cypress:run:report"
  },
  "keywords": ["automation"],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cypress": "^13.6.3",
    "@cypress/grep": "^4.0.1",
    "cypress-file-upload": "^5.0.8",
    "mochawesome": "^7.1.3",
    "mochawesome-merge": "^4.3.0",
    "mochawesome-report-generator": "^6.2.0"
  },
  "dependencies": {
    "cypress-iframe": "^1.0.1"
  }
}
```
{% endcode %}


{% endtab %}
{% endtabs %}

## **Automation Project Structure**

The Cypress automation project should adhere to the following basic folders and file structure:

* **cypress/**
  * **fixtures/**
  * **integration/**
  * **plugins/**
  * **support/**
* **node\_modules/**
* **cypress.json**
* **package.json**

<figure><img src="https://lh7-us.googleusercontent.com/EArNw98jTheFCdEehRpYCXdrdHCPmcZ_G1B2cl6sRbDZIPI2mmJjYW1Qi9he8NZVB3sSM17JHkZ2SECuuFQFxCpn1dkCm9xdxHqS7yOrO_at8fbZ2LxThvtlGi9MFV_M4uo_mrdhYQ4A" alt=""><figcaption></figcaption></figure>

This structure ensures organization and clarity within the project, facilitating efficient development and maintenance of automated tests.
