@pumpo5.dev/core
Pumpo no.5 for Playwright
This is a package for running Playwright tests in a Selenoid test farm.
It will start an instance of Chrome in a test farm for each test case, send commands using the Chrome DevTools Protocol, and close the session in the end.
At the moment only Chrome browser is supported. Firefox and Webkit (Safari) browsers are not supported.
Getting Started
Assuming that you already have one or more Playwright test suites ready in your system, all you need to do is:
- Install this package in your project.
- Import the test and expect functions from the '@pumpo5.dev/core' package
Installation
Install this package in your project which includes the Playwright tests:
$ npm install --save-dev @pumpo5.dev/core
Or if you prefer Yarn:
$ yarn add --dev @pumpo5.dev/core
Import the functions in your tests:
...
import { test, expect } from '@pumpo5.dev/core'
...
And just write your tests using the test and expect functions like you usually do.
Usage
In order connect to a test farm, you need to create a configuration file. This file must be named config.conf.
Before any tests are executed, the package will load and look for this file in three ways:
First, it will check if an environment variable named CONFIG_PATH is set.
If it is, it will then check its value and verify if it is a path that points to a file named config.conf.
In case positive, it will then try to load the configuration by reading this file.
Second, if no CONFIG_PATH environment variable is set, the package will check if a command line argument was passed to NodeJS contaning a path to any file named config.conf. In case positive, it will then try to load the configuration by reading the file pointed by this command line argument.
Third and last, in case the other methods failed, the reporter will look for a config.conf file in the project's root folder and directories above.
In case it finds a config.conf in any of those directories it will proceed to load it and use it to set its internal configuration.
The keys that could or should be included in this configuration file are as follows:
| Key | Type | Mandatory | Description |
|---|---|---|---|
| webdriverUrl | String | Yes | The URL where the test farm is running. For example, if you have it running in your localhost, it could be http://localhost:4444 |
| chromeOptions | Object | No | The initialization options for the Chrome browser, passed as desired capabilities (e.g. goog:chromeOptions. Must be contained in one line. For example chromeOptions={"args": ["--start-fullscreen"]}). Default value is an empty object {}. |
| browserName | String | No | The browser name to be passed in capabilities to Selenoid. For example, _browserName="chrome". Default value is chrome |
| browserVersion | String | No | The browser version to be passed in capabilities to Selenoid. For example, browserVersion="latest". Default value is latest |
| timeZone | String | No | The time zone to be used in the browser session. For example, timeZone="Europe/Warsaw". Default value is UTC |
| sessionTimeout | String | No | How long a session can stay idle before being closed. Provide a value using the Golang duration format e.g. 30m or 10s or 1h5m. For example, sessionTimeout="1m". Default value is 1m |
| testerName | String | No | The tester's name, to be displayed in Selenoid UI. For example, testerName="John Doe". Default value is No tester name |
Other versions
If you like this project, please check Pumpo#5 in Java as well, here and here :)
Authors
- Alvaro Silva - Initial work - Linkedin