-
Documentation
Project to experiment with Microsoft Playwright framework, and writing browser automated tests in Node.js environment in general.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What things you need to install the software and how to install them.
- Node.js - javascript runtime - you really need this :)
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
-
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:
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
.
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
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
.
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.
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.