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

sg-protractor-tools

v1.0.4

Published

Library of reusable helper functions for testing HTML5 applications with Protractor

Downloads

739

Readme

sg-protractor-tools

Build Status

Version: 1.0.4

This library provides a reusable and generic set of helper functions for the Protractor test framework, which SunGard is using for testing its HTML5-based user interfaces. It includes functions that simplify things like browser resizing, scrolling and memory usage tracking as part of a test suite. The project bundles an example application that showcases the functionality.

While using Protractor for testing our Angular-based applications, we have found that we can simplify many of the common tasks done as part of part of our test suite. The Protractor API is fairly low-level in some cases, and we have seen that we can cut down the amount of code for some common tasks by externalizing functionality into a reusable library.

The docs folder has more detailed information about the provided functionality, but here are some highlights:

Functional Overview

Memory Tracking

The library provides functionality for tracking your app's memory consumption as part of a Protractor test. When running multiple iterations of the same operation, this can be used to detect memory leaks in your application's code. To make things as easy as possible, we have encapsulated the required code in a simple function that allows you to focus on your test. The library takes care of running your test a configurable number of times, and it also takes care of tracking the memory usage. Once the test has been completed, you can use the generated CSV file to analyze the memory usage, and you can also get a quick overview by taking a look at the generated PNG diagram. Here's an example:

An example memory diagram

The above image shows an example diagram for a test case with 250 iterations. As you can see from the diagram, the used JS Heap size keeps increasing and is never reclaimed. Clearly someone hasn't been doing their homework, this is a pretty big memory leak!

Take a look at the memory.md file to see the API for running a test that's tracking memory consumption, and check out the memory.spec file for the library in action. The test code that you need to write is only a couple of lines:

it('should increase the memory consumption', function () {
    var iterations = 250;

    sgpt.memory.runTestFunction(this, iterations, function () {
        // This test function will be called 250 times, and the memory is measured after each iteration.

        // Your test code goes here.
    });
}, 100000);

Note: The memory tracking functionality only works in Google Chrome, when started with the enable-precise-memory-info and js-flags=--expose-gc flags. Other browsers currently don't expose a similar API. Take a look at the example/protractor.conf.js file to see the required configuration.

Minor helper functions

In addition to the memory tracking, the library also includes functions that simplify common tasks like

  • Resizing the browser window
  • Scrolling to an element
  • Drag and drop
  • Waiting for DOM elements to become visible or hidden

Setup

To include this library in your own project, use the following command:

npm install --save-dev sg-protractor-tools

This will include the library in your project's package.json file as a development dependency.

Usage

To use the library in your code, use the following code to import it:

var sgpt = require('sg-protractor-tools');

This will expose the libraries main object as sgpt in your code. You can use the library's functions by referencing the sgpt object, e.g. for scrolling:

sgpt.scroll.scrollTo(...);

The library's functions are split up by their domain, e.g. all functions relating to resizing windows are grouped under the sgpt.resize object. Take a look at the docs folder for more information.

Examples

The example folder contains an example application with e2e tests that showcase how to use this library with Protractor.

The README.md file in the example folder lists all the tests that you can run, gives details about each one, as well as guidance on how to run them.

Documentation

Detailed documentation on the library's functions can be found in the docs folder.

Contributing

This project uses Git-Flow as its development model. Any changes need to be made against the develop branch.

Pull requests are welcome - please stick to the coding style used in the rest of the library. When adding/changing functionality, please provide/update the following:

  • Documentation in the docs folder.
  • An example showcasing the new functionality in the example application.

Local Installation

  • Clone the project to a local folder
  • Use npm link to install it locally
  • Use npm link sg-protractor-tools in your application's directory to install the local development version

Release

Use the following commands to create a new release if required:

grunt release --releaseVersion 0.2.0 --developVersion 0.3.0-SNAPSHOT

Dependencies

License

Copyright © SunGard 2015. Licensed under the MIT license.