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

protractor-testability-plugin

v2.0.2

Published

[![Build Status](https://travis-ci.org/alfonso-presa/protractor-testability-plugin.svg?branch=master)](https://travis-ci.org/alfonso-presa/protractor-testability-plugin)

Downloads

752

Readme

protractor-testability-plugin

Build Status

This plugins enables testing projects and libraries not built against AngularJS services in sync with protractor (without having to set ignoreSynchronization=true). Even when using AngularJS there are situations when this plugin my become useful, like when using webworkers or comunicating via websockets.

This means that your TDD/BDD tests will be a lot cleaner as you will not have to add aditional waitings and tweak timeouts to get your tests passing consistently as protractor will know when there's a task pending and it will wait automatically between each step for it to get completed.

If you're coding a reusable front end library, you definitely should consider notifying testability.js when doing something asynchronous as it will make e2e testing in projects using your library a lot more easy.

Installation

Execute the following from a command line inside your project:

npm install --save-dev protractor protractor-testability-plugin

Now add this to protractor.conf.js ()

plugins: [{
	package: 'protractor-testability-plugin'
}],

Automatic waits

This plugin will make protractor wait automatically for the following async events:

  • Ajax requests
  • setTimeout/clearTimeout: only if it's time is below 5 seconds, because otherwise it's considered a timeout.
  • setImmediate/clearImmediate
  • fetch

Advanced Usage

Check https://github.com/alfonso-presa/testability.js to see how to make testings frameworks wait for your libraries and applications.

Basically everytime you are doing something asynchronous that is not using angular's $http or $timeout, or is not in the automatic waits, you should do:

testability && testability.wait.for(myPromise);

This plugin will include testability.js in the page for you when testing in protractor, but it will not be there in other situations. You can avoid checking for the testability object everytime if you include it directly on the page.

Also check the test/samples folder of this repo for some working examples.

Map Protractor browser methods to any framework

Angular provides a testability object that includes methods like setLocation(url) for Protractor to use as browser.setLocation(url). This plugin allows you to set customFrameworkTestability to an object of methods to map them to the framework of your app.

exports.config = {
    plugins: [
        {
            package: 'protractor-testability-plugin',
            customFrameworkTestability: {
                // Methods go here
            }
        }
    ]
};

All current Protractor browser methods can be found here for v4.0.8: see all uses of angular.getTestability(). If you are not using v4.0.8, check the source code for the version of Protractor you are using. Also try searching for getTestability to see what methods Protractor is trying to use.

Generally, if Protractor errors when you are trying to use a browser method in your tests for a non-Angular app, see if the error names a function that is missing: you can then provide that function via customFrameworkTestability.

Example

In a Backbone app, to enable use of browser.setLocation() in your tests, include the following with this plugin's configuration:

exports.config = {
    plugins: [
        {
            package: 'protractor-testability-plugin',
            customFrameworkTestability: {
                setLocation: function (route) {
                    Backbone.history.navigate(route, true);
                }
            }
        }
    ]
};

License

MIT