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 allure
Node:
$ scoop install nodejs
Yarn:
$ scoop install yarn
To 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:
$ yarn
IMPORTANT:
- 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=[email protected]
PASSWORD=teste
After 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 install
The 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:api
To run all UI tests:
$ yarn test:e2e
To run debug mode:
Set PWDEBUG: set PWDEBUG=1
$ PWDEBUG=1 yarn test:e2e
To run with open browser mode:
$ npx playwright test --headed
Tips: To run on Docker for API tests
First: Open docker
$ yarn api:start
$ yarn test:api
Tips: To run on Docker for E2E tests
First: Open docker
$ docker-compose up -d
Reports 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:generate
Now, a folder called: allure-results
or test-results
will be created.
To generate the report inside an allure server:
$ yarn allure:serve
To open the HTML with the report:
$ yarn posttest
- Linkedin: Lucas Fraga
- MIT license
- Copyright 2023 © LUCAS FRAGA