Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Experimental project to explore javascript cross-browser automation library MS Playwright, running on Node.js

License

Notifications You must be signed in to change notification settings

Tesena-smart-testing/playwright-js-template-project

Repository files navigation

playwright-playground

code style: prettier linter: eslint:recommended Continuous Integration

Table of Contents

About

Project to experiment with Microsoft Playwright framework, and writing browser automated tests in Node.js environment in general.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install the software and how to install them.

  • Node.js - javascript runtime - you really need this :)

Installing

How to get a development/ testing running.

Clone the repo:

git clone https://github.com/Tesena-smart-testing/playwright-js-template-project.git

Be in the root of the project and install and update all dependecies:

npm install
// if update happens, do not commit changes to the master!!!
npm update

Test development

Core rules

  • do not push to the master - I will revert it, no questions asked

  • CI pipeline with linting and formatting checks for pull requests is set up, but still use on your development local:

    • eslint - to check, catch and remove errors, bugs. Has plugin in VScode
    • prettier - to keep code formatting consistent. Has plugin in VScode.

Documentation

Codebase (test files included) docs are generated via Documentation.js tool. Check its documentation to figure out how to work with it, or use predefined npm scripts in package.json.

Usage

Tests are run using Mochajs framework. See documentation for details, but general syntax looks like this:

./node_modules/.bin/mocha test/spec/** -t <timeout-in-ms> [...args]

If some arguments are always passed, put them into .mocharc.json file in the root and run:

./node_modules/.bin/mocha test/spec/** --config .mocharc.json

To further shorten the work, you can use predefined npm test script in package.json file and run all tests by:

npm test

Reporting

Test results are reported into the console, by default spec reporter.

Currently, as Mochajs introduced native support for parallel execution, most third party reporters stopped working properly or at all in this mode.

For example, excellent reporters Mochawesome or Allure were hit by this.

AFAIK, Mochawesome author is aware of this issue, and investigates how to fix this.

If you want to use Mochawesome or Allure, do not run test specs in parallel, but sequentially - disable this option in .mocharc.json.

Report Portal

Reporting to ReportPortal was added. Since this is paid service, files with API credentials are not pushed in this repo.

To connect to ReportPortal, you can use agent for Mochajs.

You have to start Mochajs programatically - so we created runner file, which is then executed by npm script. You can of course play with this and by parametrization do the adjusting for your real world needs.

Screenshots

Currently there is a method implemented, which saves full page screenshot, if test fail. Since we are reporting only to the console now, we are just storing the screenshots to ./screenshots directory.

You can see, how that works, since one test from spec homepage.test.js is set to fail.

About

Experimental project to explore javascript cross-browser automation library MS Playwright, running on Node.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published