npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@creately/pluto

v1.0.2

Published

An end-to-end testing framework.

Downloads

3

Readme

npm package

Pluto: An end to end testing framework.

"Don't forget your e2e tests"

Pluto is an e2e testing framework that uses Selenium to execute test cases. It includes interfaces for tests that can be written for specific cases, a set of asserts, and types that define specs and tests.

Installation

Install Pluto as a global npm package (or locally to your project by omitting -g)

$ npm install -g @creately/pluto

Note: When installing the package globally, your $NODE_PATH environment variable should be set to the global package directory.

Linux / Mac

If it isn't set already, add the following to .bashrc or .zshrc :

$ export NODE_PATH=$(npm root --quiet -g)

Windows

Add an environment variable named NODE_PATH and set it to %USERPROFILE%\Application Data\npm\node_modules (Windows XP) or %AppData%\npm\node_modules (Windows 7/8/10), or whichever path NPM uses to install modules in your environment.

See Loading from the global folders for more configuration information.

Set up Chrome and Firefox webdrivers for Selenium

Webdrivers should be downloaded and installed for the browser versions available in the environment. Webdrivers and installation instructions can be found on the Official Selenium Docs.

Usage

Actions

An action will be a class with a single method named execute which performs one specific action. The framework executes the action instance's execute method when the action is run.

A Selenium WebDriver instance will be loaded into the context object which is passed as the second argument to the execute method, having been initialised with the arguments provided to Pluto (if any) when running the package.

See the Action Interface for more information.

Using Selenium in actions

You may install TypeScript definitions for Selenium Webdriver in your project to write actions using Selenium.

$ npm install @types/selenium-webdriver

Example Action

// go-to.action.ts

import { By, until, WebDriver } from 'selenium-webdriver';

/**
 * Navigates to the specified URL.
 */
export default class GoTo {
  async execute(args: string[], context: any): Promise<string[]> {
    // Get the WebDriver instance
    const driver: WebDriver = context.driver;

    // Get the first arg, which is the URL in this case
    const url = args[0];

    // Navigate the page to the given URL
    await driver.get(url);

    // Return an empty string array as this action has no result
    return [''];
  }
}

Tests & Specs

Tests can be written in JavaScript or TypeScript (which will be compiled by Pluto at runtime), and have the extension *.test.js or *.test.ts respectively. They should contain a series of specs for that particular test.

A single spec is defined by a title, an action or assert to be run, and an array of args and/or outs. Any output expected from an action should be assigned to meaningful keys in the outs array, so that that they may be used in future actions or asserts. This way, specs can be chained to form a test, as they will be run sequentially.

See the Spec Type for more information.

Example Test

// simple.test.ts

const pluto = require('@creately/pluto');
import GoTo from '../go-to.action';
import GetUrl from '../get-url.action';

pluto.registerActions(GoTo);

pluto.addTest('simple test', [
    {
        title: 'goes to creately demo start page',
        action: GoTo,
        args: ['https://creately.com/demo-start']
    },
      {
        title: 'gets the current URL',
        action: GetUrl,
        outs: ['$url']
    },
    {
        title: 'checks URL has changed',
        assert: pluto.Equals,
        args: ['$url', 'https://app.creately.com/diagram/create']
    },
]);

Running tests

Run pluto in the directory containing test files or pass the relative or absolute path to the directory or file with the --path argument. Below is a list of other arguments that can be passed. By default, tests run on Chrome in headless mode using the Chromium webdriver, with the default window size set by Selenium.

| Argument | Description | | ---------------------|:-------------------------------------------------------| | --path=\Users\... | The path to look for test files in | | --help, -h | Show help | | --show, -s | Show browser instead of running in headless mode | | --keep-open, -o | Keep browser open after tests are complete | | --devtools, -d | Show devtools on open | | --firefox, -f | Use Firefox instead of Chrome | | --maximise, -m | Maximise browser window on open |

Attributions

Love vector created by freepik - www.freepik.com

Watercolor vector created by freepik - www.freepik.com