Sample project to demonstrate Playwright Test usage, pointing to ServeRest API and Front-end

Overview

Badge ServeRest

demo-playwright-test

This is a sample project to demonstrate Playwright Test usage, running tests against ServeRest API and Front-end.

Pre-requisites

Node.js

Make sure to have the correct Node version installed, which can be found in .nvmrc file in the repository root. It is recommended to use nvm to manage different Node versions in your environment.

Yarn

The project also uses Yarn, so follow the installation steps in case you don't have it.

Docker

The projects used Docker to spin up ServeRest API. Follow instructions from their official docs to install Docker engine in your environment.

Structure

Code is structured as shown below:

demo-playwright-test/
 ├── lib/
 │    ├── helpers.js                        # Helper functions used in tests
 ├── tests/
 │    ├── api
 │         ├── login.api.test.js            # API tests
 │    ├── e2e
 │         ├── create-user.e2e.test.js      # End-to-end tests
 ├── playwright.config.js                   # Playwright configuration file

PS: Note that different test levels are configured to have proper extensions (e.g: *.api.test.js).

Running locally

  • Install dependencies: yarn install
  • Start Serverest server: yarn api:start
  • Run API tests: yarn test:api
  • Run End-to-end tests: yarn test:e2e

Tips

  • To stop running ServeRest container: docker stop serverest
  • To restart ServeRest container: docker restart serverest
  • To remove ServeRest container (no need to stop it first, the -f option will force its removal even if it is running): docker rm -f serverest

Reporting

Test reports can be generated with Allure reports, following the steps below:

  • Generate report: yarn allure:generate
  • Open HTML report: yarn allure:open

CI

The project uses GitHub Actions and tests are run automatically on PRs and on merge to main branch.

Comments
  • Setup visual and a11y tests

    Setup visual and a11y tests

    Description

    Setting up a sample a11y test with axe-playwright and a couple of visual regression tests using happo-playwright integration. Also, configured a CI job for visual regression tests and enabled Happo app in the repository.

    How to test

    • yarn install
    • Check a11y test in tests/e2e/create-user.e2e.test.js (it's skipped as it will always fail, since the component has a11y issues)
    • To run visual regression tests: yarn test:visual (you will need an account on Happo to run it locally)
    • Check Happo report with added screenshots

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by stefanteixeira 3
  • Add example of schema validation test with Joi

    Add example of schema validation test with Joi

    Description

    Adding a simple schema validation test with Joi, to demonstrate how it can be done. Also, removing expect-playwright lib, which was unnecessary (closes #42)

    How to test

    • yarn install
    • yarn api:start
    • yarn test:api

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by stefanteixeira 2
  • configuring gh-pages - waiting for environment configuration.

    configuring gh-pages - waiting for environment configuration.

    Description

    Add config - gh-pages #10

    How to test

    • ND

    Comments

    This PR needs admin help to choose gh-pages in config. @stefanteixeira 🐤

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review help wanted work in progress 
    opened by uLucasFraga 2
  • Add API test for

    Add API test for "Product not found" scenario in Product API

    Description

    Add API tests for Product not found scenarios in the task can be seen here.

    How to test

    • yarn install && yarn api:start && yarn test:api

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by uLucasFraga 1
  • Add http-status-codes lib on the API tests

    Add http-status-codes lib on the API tests

    Description

    Add http-status-codes lib on the API tests: lib here.

    PS: Refactor all API tests.

    Acceptance Criteria

    • Add lib on the tests created: tests/api/*.api.test.js
    • Check the use of awaits in the validation of expect.
    • Test is stable and successfully passing on CI
    opened by uLucasFraga 1
  •  Add API tests for complete order and cancel order actions

    Add API tests for complete order and cancel order actions

    Description

    I'm creating new test scenarios to cancel and delete an order in the cart.

    The task can be seen here.

    How to test

    • yarn install && yarn test:api

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by uLucasFraga 1
  • [#13] add new api tests for complete order and cancel order actions

    [#13] add new api tests for complete order and cancel order actions

    Description

    I'm creating new test scenarios to cancel and delete an order in the cart.

    The task can be seen here.

    How to test

    • yarn install && yarn test:api

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by uLucasFraga 1
  • [docker] add docker for local tests in Servertest

    [docker] add docker for local tests in Servertest

    Description

    Adding a job with docker for local tests

    How to test

    • NOTHING

    Comments

    This PR needed to change the baseURL to run locally. In the future, I'd like to use it with an env or in another "smarter" way. 😆

    Checklist

    • [x] Branch name follows the pattern: feature-description
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    • [x] PR has a descriptive name
    ready to review 
    opened by uLucasFraga 1
  • Update serverest package on project

    Update serverest package on project

    Description

    Update serverest package on project: 2.62.2v.

    Comments

    This change modified the project constants. Due to this change, I refactored the necessary tests and updated the package.json.

    How to test

    • yarn install && yarn api:start && yarn test:api

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by uLucasFraga 0
  • Remove expect-playwright library

    Remove expect-playwright library

    expect-playwright library is not necessary, since the Locator assertions from Playwright Tests cover all the necessary cases and can cause conflicts.

    Acceptance Criteria

    • Remove dependency from package.json
    • Remove its references from the config file and any existing test
    opened by stefanteixeira 0
  • Update serverest package on project

    Update serverest package on project

    Description

    Update serverest package to latest stable version: SERVEREST The naming of all its constants has been changed for a correct usage pattern and other necessary improvements.

    Docker Image: https://hub.docker.com/r/paulogoncalvesbh/serverest

    Acceptance Criteria

    • Edit tests that are using the serverest package, ex: tests/api/product.api.test.js file
    • New test follows the same approach and naming conventions as the existing ones
    • Test is stable and successfully passing on CI
    opened by uLucasFraga 0
  • Add e2e for search product functionality

    Add e2e for search product functionality

    Description

    Adding new scenarios for e2e testing of search a product. Also, edited Helper lib. The task here.

    How to test

    • yarn install
    • yarn api:start
    • yarn test:e2e

    Checklist

    • [x] Branch name follows the pattern: concise-feature-description
    • [x] PR has a descriptive name
    • [x] PR branch is up-to-date with main (if not, rebase it)
    • [x] Double-check the quality of commit messages
    ready to review 
    opened by uLucasFraga 0
  • Add API tests for

    Add API tests for "Route exclusive for admin users" scenarios in Product API

    Description

    Add API tests for "Route exclusive for admin users" scenarios in Product API. Make sure to cover it for POST, PUT and DELETE methods.

    PS: To avoid hardcoding the error message, let's simply assert that the response status is 403.

    Screen Shot 2022-08-01 at 21 00 32

    Acceptance Criteria

    • New tests are created in the current tests/api/product.api.test.js file
    • New tests are following the same approach and naming conventions as the existing ones
    • Tests are stable and successfully passing on CI
    opened by stefanteixeira 0
  • Add End-to-end test for Search Product functionality

    Add End-to-end test for Search Product functionality

    Description

    Add End-to-end tests for Search Product functionality (accessible from https://front.serverest.dev/home page).

    Ideally, it should perform the following steps:

    • Make an API request to create a product (check tests/api/product.api.test.js for an example, but remember to point the request to ServeRest Production API).
    • Login as a regular user
    • Search by the product name
    • Verify that there is a single result containing that product

    Acceptance Criteria

    • Tests are properly using Playwright's Locator API (tip: create-product.e2e.test.js for a similar example of Locator usage)
    • Tests are added in a proper test file, such as tests/e2e/search-product.e2e.test.js
    ready to review 
    opened by stefanteixeira 0
  • Add End-to-end tests for Add Product to List and Delete Product List functionalities

    Add End-to-end tests for Add Product to List and Delete Product List functionalities

    Description

    Add End-to-end tests for Add Product to List and Delete Product List functionalities (accessible from https://front.serverest.dev/home page).

    Ideally, it should perform the following steps:

    • Login as a regular user
    • Add the first product to the list, by clicking Add to List button
    • Verify that the user got redirected to /minhaListaDeProdutos
    • Verify that there is only 1 product being displayed

    Acceptance Criteria

    • Tests are properly using Playwright's Locator API (tip: create-product.e2e.test.js for a similar example of Locator usage)
    • Tests are added in a proper test file, such as tests/e2e/product-list.e2e.test.js
    opened by stefanteixeira 0
  • Add End-to-end test for Logout functionality

    Add End-to-end test for Logout functionality

    Description

    Add End-to-end test for Logout functionality.

    Ideally, it should perform the following steps:

    • Login as Admin user
    • Click on Logout button
    • Verify that the user is redirected to Login page

    Acceptance Criteria

    • Tests are properly using Playwright's Locator API (tip: create-product.e2e.test.js for a similar example of Locator usage)
    • Tests are added in a proper test file, such as tests/e2e/logout.e2e.test.js
    opened by stefanteixeira 0
  • Add End-to-end tests for Delete User functionality

    Add End-to-end tests for Delete User functionality

    Description

    Add End-to-end tests for Delete User functionality (accessible from https://front.serverest.dev/admin/listarusuarios page).

    Ideally, it should perform the following steps:

    • Login as Admin user
    • Create a dummy user (tip: use the API helper for that 💡 , but remember to point the request to ServeRest Production API)
    • Open /admin/listarusuarios
    • Click on Delete button for the user you created
    • Verify that the user is not visible on the list

    Acceptance Criteria

    • Tests are properly using Playwright's Locator API (tip: create-product.e2e.test.js for a similar example of Locator usage)
    • Tests are added in a proper test file, such as tests/e2e/delete-user.e2e.test.js
    opened by stefanteixeira 0
Owner
Stefan Teixeira
Stefan Teixeira
Personal Blog - a project developed with Angular for the front-end interface and Wordpress for the back-end API served with Docker containers

PersonalBlog This project was generated with Angular CLI version 13.0.1. Front-end Interface Development server Run ng serve or ng serve --configurati

null 9 Oct 5, 2022
This is an example project to demonstrate how to use Nx, Next.js and Module Federation together.

Nextjs, Nx and Module Federation This is an example project to demonstrate how to use Nx, Next.js and Module Federation together. ⚠ This example depen

Bruno Silva 14 Nov 28, 2022
It consists of a recreation of Twitter, to put into practice both Front-end and Back-end knowledge by implementing the MERN Stack together with other technologies to add more value to the project.

Twitter-Clone_Back-end ✨ Demo. ?? About the project. ?? Descriptions. It consists of a recreation of Twitter, to put into practice knowledge of both F

Mario Quirós Luna 5 Apr 12, 2022
It consists of a recreation of Twitter, to put into practice knowledge of both Front-end and Back-end implementing the MERN Stack along with other technologies to add more value to the project.

Twitter-Clone_Front-end ✨ Demo. Login Home Profile Message Notifications Deployed in: https://twitter-clone-front-end.vercel.app/ ?? About the project

Mario Quirós Luna 5 Jun 26, 2022
Three.js boilerplate project configured with typescript, webpack and css/style loader, HTTPS local server, and a sample test codes !!

three.js-boilerplate Welcome, this is a three.js boilerplate project where you can clone it and start to work !!! Installed and Configured Items: Type

pravin poudel 4 Jul 6, 2022
A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.

Front-end Developer Interview Questions This repository contains a number of front-end interview questions that can be used when vetting potential can

H5BP 56.1k Jan 4, 2023
10lift Applicant Test Senior Front End Development

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: ya

Barış ÖZDEMİRCİ 2 Sep 27, 2021
No-code test automation solution for end-to-end testing

No-code test automation tool for end-to-end testing Table of Contents About Features Installation Usage Creating tests Running tests Roadmap Our Team

OSLabs Beta 63 Oct 18, 2022
Web-Technology with Aj Zero Coding. In this tutorial we learn front-end and back-end development.

Installation through NPM: The jQWidgets framework is available as NPM package: jQuery, Javascript, Angular, Vue, React, Web Components: https://www

Ajay Dhangar 3 Nov 19, 2022
This a generic startpage to demonstrate the react startpage library.

This startpage is the official usage demo of the @startpage library. Yet another generic startpage A startpage with a generic layout and many settings

PrettyCoffee 98 Dec 30, 2022
This Repo Contains projects that demonstrate some concepts / algorithms / implemetation in some form of digital visualisation

Hacktoberfest 2022 OPEN FIRST Pull Request - GET STARTED WITH OPENSOURCE AND WIN SOME AWWSOME SWAGS ?? Contributors of Hacktoberfest 2022 This project

null 5 Nov 7, 2022
Pass trust from a front-end Algorand WalletConnect session, to a back-end web service

AlgoAuth Authenticate to a website using only your Algorand wallet Pass trust from a front-end Algorand WalletConnect session, to a back-end web servi

Nullable Labs 16 Dec 15, 2022
A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM deffiniation and appropriate file structure.

Welcome to function-stencil ?? A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM

Ben Smith 21 Jun 20, 2022
This repository contains an Advanced Zoom Apps Sample. It should serve as a starting point for you to build and test your own Zoom App in development.

Advanced Zoom Apps Sample Advanced Sample covers most complex scenarios that you might be needed in apps. App has reference implementation for: Authen

Zoom 11 Dec 17, 2022
Front-End mentor project for rest maps API😊👍

REST Countries API with color theme switcher Live | Solution | Challenge Solution for a challenge from frontendmentor.io. About The Project If you're

Ashutosh Mohanty 3 Sep 4, 2022
Automagically bypass hcaptcha challenges with http api, with puppeteer, selenium, playwright browser automation scripts to bypass hCaptcha programmatically

Automagically bypass hcaptcha challenges with http api, with puppeteer, selenium, playwright browser automation scripts to bypass hCaptcha programmatically. For help you can message on discord server with the bellow link. You can also create an issue.

Shimul 199 Jan 2, 2023
Atividade do Módulo 03 - Especialização em Front-end - Turma 01; Criação de uma API de Rick and Morty com React.js.

Screenshots Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you

Daniela 0 Dec 1, 2021
A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

Live Demo · Twitter A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Pris

Remix Stacks 18 Oct 31, 2022
Scrape tweets from Twitter search results based on keywords and date range using Playwright. Save scraped tweets in a CSV file for easy analysis

Tweet Harvest (Twitter Crawler) Tweet Harvest is a command-line tool that uses Playwright to scrape tweets from Twitter search results based on specif

Helmi Satria 33 Aug 9, 2023