Coder Social home page Coder Social logo

playwright-seed's Introduction

Playwright seed

Initial setup for Playwright automation project:

  • typescript
  • eslint with precommit hooks
  • mochajs runner
  • chaijs assertion library
  • global mocha hooks
  • different environments support
  • docker support
  • entrypoint for local or docker run
  • page objects
  • api controller based on axios
  • check API response with json schema
  • allure reporter with logs and screenshots

Docs

Global setup

Use this file for global setup and/or teardown.

Examples: create test data before all or each test, open/close page or browser itself, add data to the report, so on. For more details please see: https://mochajs.org/#root-hook-plugins

Supported CLI parameters:

grep - [string] filter test names;

suites - [string] filter test filenames;

headless - [boolean] switch headless mode for the browser;

slowmo - [number, milliseconds], add a delay after the browser action during tests execution;

browser - [chromium/firefox/webkit], browser for the test run.

Entrypoint run

To run tests locally or in docker please use entrypoint file. You can use all CLI parameters from the list above.

Local run examples:

env=api:qa ./entrypoint.sh - will run only api tests on qa environment;

headless=false env=e2e:qa suites=login ./entrypoint.sh - will run only end-to-end login tests on qa environment in headful mode;

env=all:qa grep=test ./entrypoint.sh - will run all tests on qa environment with test in title;

Docker examples:

Please use docker:base script to build the image and docker:test to run tests. Use the same grep/suites parameters via docker --env.

Browser instance

Please make sure you call await browser.getPage() to get a new browser context and page before each test. It's needed because we close all contexts after each test in root hooks.

Page objects

Please see login page for page object example. This page contains examples how to initialize ui element and ui widget. The main concept of widgets: to split all page elements to logical blocks for better understanding and maintenance. It's like a page object inside the other page object :) It's better to use ui widgets for pages with multiple ui elements, if you have up to 5 elements on the page please use KISS principle.

API Controller

Please see example of API-test here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.