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-e2e-framework

v1.0.9

Published

Protractor e2e framework

Downloads

5

Readme

Protractor E2E Framework Build Status Coverage Status

Typescript library that interfaces with protractor test development framework, offering some helpers and an automatic navigation interface by 'NavigationFlow' and a navigationRouteBook, which can change from test to test for define application navigation actions

Installation

install npm package

$ npm install --save-dev protractor-e2e-framework

Getting started

Define browser url schema model like
{
    "base": "/",
    "urls": {
        "base":""
        "signIn" : "/account/sign-in",
        "home-page" : "/home",
        "post-detail-page" : "/posts/PostId-(\\d+)",
        ..,
        ..
    },
    "paramethers": {
        "PostId": "001",
        ..,
        ..
    }
}

each node defines

  • base page navigation url
  • each navigation page urls
  • navigation page urls paramethers
    • when ask for navigate to 'post-detail-page' the compiled url is "/posts/PostId-001"

Extends pages with BasePage
import { BasePage } from 'protractor-e2e-framework';

export class BasePage extends BasePage {
    constructor() {
        // set page's browser url key
        // in basePage/workflow acts like placeholder: "start from here"
        super('base');
    }
}

import { BasePage } from 'protractor-e2e-framework';

export class SignInPage extends BasePage {
    constructor() {
        // set page's browser url key
        super('signIn');
    }
}

Define navigations flows
import { NavigationBaseFlow, FrameworkConfiguration } from 'protractor-e2e-framework';
import { Deferred } from 'ts-deferred';

/**
 * base navigation flow
 */
export class BasePageNavigationFlow extends NavigationBaseFlow<BasePage> {
    /**
     * init base page navigation flow
     */
    constructor() {
        // set workflow page
        super(BasePage);
    }
    /**
     * load browser default url
     */
    public navigateTo(): Promise<void> {
        const d: Deferred<void> = new Deferred<void>();
        // navigation flow actions
        browser.get(FrameworkConfiguration.browserData.base).then(() => {
            d.resolve(this.pageInstance);
        }).catch(d.reject);
        return d.promise;
    }
}

/**
 * signIn navigation flow
 */
export class SignInPageNavigationFlow extends NavigationBaseFlow<SignInPage> {
    /**
     * init signin page navigation flow
     */
    constructor() {
        // set workflow page
        super(SignInPage);
    }
    /**
     * load signin page
     */
    public navigateTo(): Promise<any> {
        const d: Deferred<any> = new Deferred<any>();
        
        //argument validation
        if (_.isEmpty(this.fromNavigationFlow)) {
            d.resolve(this.pageInstance);
            return d.promise;
        }
        // navigate to base navigation
        this.fromNavigationFlow.navigateTo().then((previousPage: BasePage) => {
            // navigation flow actions
            
            //do something with 'previousPage' for reach signInPage (like clicks, browser navigation ecc..)
            
            //resolve returning page
            d.resolve(this.pageInstance);

        }).catch(d.reject);
        return d.promise;
    }
}

Inside each 'beforeEach' functions
import { FrameworkConfiguration } from 'protractor-e2e-framework';
import { BasePageNavigationFlow, SignInPageNavigationFlow } from './navigation-flows';

const mockData = require('../resources/mockdata.json');
const browserData = require('../resources/browser-urls.json');

beforeEach(function() {
    // reset all previouis settings
    FrameworkConfiguration.reset();
    
    // setup browser urls
    FrameworkConfiguration.browserData = browserData;
    
    // setup whatever mock datas you need
    FrameworkConfiguration.mockData = mockData;
    
    // #region navigation flows registrations
        
        // flowBook registration - can be done by 'from-to' funcion or by chain
        // for reach SignInPage i should navigate from BasePage
        FrameworkConfiguration.registerFlow('base', 'signIn');
        // for reach HomePage i should navigate from BasePage then SignIn
        FrameworkConfiguration.registerFlow('base','signIn')
                            .append('home-page');
                            
        // register by browser url id and type
        FrameworkConfiguration.registerType('base', BasePageNavigationFlow);
        FrameworkConfiguration.registerType('signIn', SignInPageNavigationFlow);
    // #endregion
    
    // runs with workflows
        FrameworkConfiguration.workflowNavigationEnabled = true;
    // runs with urls
    // FrameworkConfiguration.workflowNavigationEnabled = false;
});

Use in tests

it('should login', function (done) {
        let signInPage = new SignInPage();
        // based on setups go to page url by workflows or url
        signInPage.goToPageUrl()
        .then(() => {
            // do login operations and expects
        }).catch(done.fail);
    });

Problems? Please let us know

If you run into any problems or issues, please let us know so we can address and fix them right away. You can report issues on GitHub: