Repository with examples for studies on automated tests with Playwright for API and UI.
Tools:
- docker
- allure
- expected playwright
- faker
- http-status-codes
NOTE: The programming language chosen was JavaScript and the OS Windows.
The Playwright enables reliable end-to-end testing for modern web apps. GET TO KNOW PLAYWRIGHT
Index
README.
- Prerequisites
- Configuration
- Installation
- Structure
- How to test
- How to view the Report
- Support
- License
NOTE: The project use Node v18 (.nvmrc). It is recommended to use nvm to manage different Node versions in your environment.
Tips:
Use the Chocolatey or Scoop to download the packages.
Allure:
$ scoop install allureNode:
$ scoop install nodejsYarn:
$ scoop install yarnTo clone the project:
$ git clone https://github.com/uLucasFraga/playwright_for_studies.git- Use the terminal to install the dependencies on package.json, for example:
$ yarnIMPORTANT:
- Do not expose senstive data:
It's necessary to create a root .env file of the project as in the example: .env.example.
Use the data below:
API_SERVEREST=https://serverest.dev
E2E_SERVEREST=https://front.serverest.dev
USER=fulano@qa.com
PASSWORD=testeAfter creating the .env, your tests are ready to run.
To clean the project & install all dependencies via package.json:
$ cd /playwright-for-studies
$ yarn clean
$ yarn installThe structure of the repository follows the architecture below:
playwright-for-studies/
├── .github/
│ ├── action/
│ ├── setup/
│ ├── action.yml # Setup for the CI
│ ├── workflows/
│ ├── tests.yml # Configuration for the tests on CI
│ ├── pull_request_template.md # Template for PR on github
├── lib/
│ ├── helpers.js # Helper function for the tests
├── tests/
│ ├── api/
│ ├── login/ # Serverest API tests
│ ├── login.api.js # Serverest API tests
│ ├── e2e/
| ├── login/ # Serverest API tests
│ ├── login.e2e.js # Serverest UI tests
├── .env # Env data
├── package.json # Dependencies file for the project
├── playwright.config.js # Configuration file of Playwright
After confirming the previous settings, follow the steps below:
To run all API tests:
$ yarn test:apiTo run all UI tests:
$ yarn test:e2eTo run debug mode:
Set PWDEBUG: set PWDEBUG=1
$ PWDEBUG=1 yarn test:e2eTo run with open browser mode:
$ npx playwright test --headedTips: To run on Docker for API tests
First: Open docker
$ yarn api:start
$ yarn test:apiTips: To run on Docker for E2E tests
First: Open docker
$ docker-compose up -dReports are generated by Allure.
It's necessary to have Allure installed in the project (via package) or in your machine according to the Installation topic of this README.
To generate the report:
$ yarn allure:generateNow, a folder called: allure-results or test-results will be created.
To generate the report inside an allure server:
$ yarn allure:serveTo open the HTML with the report:
$ yarn posttest- Linkedin: Lucas Fraga
- MIT license
- Copyright 2023 © LUCAS FRAGA