0.3.3 • Published 1 year ago

pupest v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Pupest

The easiest end-to-end test automation using Puppeteer

Installation

npm install pupest
# OR
yarn add pupest
# OR
pnpm add pupest
# OR
bun add pupest

Usage

Pupest CLI automatically detects all files *.pupest.js

// login.pupest.js

import pupest from 'pupest';

pupest()
  .go('https://github.com/login')
  .type('user123', '#login_field')
  .type('pass456', '#password')
  .test('Login into GitHub')

CLI

Run for all *.pupest.js files

pupest --visible --verbose

Run for custom glob

pupest **/auth --visible --verbose

Commands

Handler Props (Type Reference)

type HandlerProps = {
  browser: Browser;
  page: Page;
  scope: Frame;
}
CommandParamsDescription
clickselector: stringClicks the element matching the selector.
clickIfExistsselector: stringClicks the element matching the selector only if exists on DOM.
commandcallback: (pupest: Pupest, ...args: any[]) => PupestExecutes custom command created previously.
containstext: string, selector?: stringChecks if the element matching the selector contains the specified text.
fileselector: string, ...paths: string[]Attaches one or more files to the element matching the selector.
findselector: stringReturns the first element matching the selector.
frameselector?: stringSwitches to the frame matching the selector (or to the main frame if no selector is provided).
gourl: stringNavigates to the specified URL.
ifElsecondition(HandlerProps), then(HandlerProps), else(HandlerProps)Executes callback "then" or "else" based on boolean returned from "condition".
keepKeeps the browser open, having to be closed manually.
presskey: KeyInputPresses the specified key.
puppeteerhandler(HandlerProps)Executes a custom handler function that receives an object with instances of the browser, page, and current frame.
screenshotpath?: stringCaptures a screenshot of the current page and saves it to the specified path (or in the test file directory).
scrollselector: stringScrolls the page until the element matching the selector is visible.
selectselector: string, ...values: string[]Selects the specified options on the element matching the selector.
typetext: stringTypes the specified text.
waitmilliseconds: numberWaits for the specified number of milliseconds before continuing.
waitAnimationEndselector: stringWaits for the animation or transition of the given selector to finish.
waitResponseURLurl: stringWaits for a response from a specified URL before proceeding. * may be used at the beginning and end of the URL

Options

bail

CLI: --bail or -b

If set to true, stops the test run on the first failure.


changed

CLI: --changed

Runs tests only on the files that have been changed. It is useful for quickly testing changes without having to run the entire test suite.


height

CLI: --height or -h

The height of the browser window in pixels. Defaults to 1080.


keep

CLI: --keep or -k

If set to true, keeps the browser open, having to be closed manually


speed

CLI: --speed or -s

The speed at which the tests are run. Can be set to 'slow', 'medium', or 'fast'. Defaults to 'fast'.


timeout

CLI: --timoeut or -t

The amount of time in milliseconds to wait for a test to complete before timing out. Defaults to 15000.


userAgent

CLI: --userAgent or -u

The user agent string to use when making requests. Defaults to a random user agent.


verbose

CLI: --verbose

If set to true, logs more information about the test run.


visible

CLI: --visible or -v

If set to true, runs the tests in a visible browser window.


width

CLI: --width or -w

The width of the browser window in pixels. Defaults to 1920.

0.3.2

1 year ago

0.3.3

1 year ago

0.3.1

1 year ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.0.21

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.1

2 years ago