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

spectangular

v0.9.9

Published

Simple Protractor e2e Component Testing for Angular

Downloads

4

Readme

Spectangular

Simple Protractor e2e Component Testing for Angular

This library helps with writing e2e tests for Angular applications by supporting the navigation to and interaction with web elements. The library uses Protactor Protractor-jasmine.

Protractor version

The current supported Protractor version is 2.1.0.

Demo application

The demo application uses Angular material

Demo spectangular

Installation

npm install

Declare the library as node module into the package.json of your application.

Development (ECMAscript 6)

Because the components are written in ECMAscript 6, the code is transpiled with Babel. During development you can watch and transpile the code automatically into the dist folder.

grunt dev

Important! The transpiled code in the dist folder is also committed! Make sure you always transpile your changes before committing changes.

Documentation (ECMA script 6)

grunt shell:doc

Generates the documentation from the base classes into the doc folder.

Example 1: login page

This example explains how to write an e2e test for a login page. The login page contains a form with two input fields, one for the username and one for the password and a submit button. The page starts on http://localhost:8080/#/inloggen.

There are small differences between ECMAscript 5 and 6 when declaring the spectangular library.

ECMAscript 6

ECMAscript 5

The example (ECMA6script) :

Spectangular

The Spectangular library is declared in the package.json in your application and as such installed with npm install. Make sure that the dist folder is used !

Adapters

Spectangular is extensible with different adapters for the support different frontend libraries. At the start of the test you have to declare adapter as a the library module.

Spectangular

import * as SpectangularMdLibrary from '../node_modules/spectangular/dist/libraries/md/md.js' Spectangular.library = SpectangularMdLibrary

Base Url

Spectangular.baseUrl = 'http://localhost:8080';;

The baseUrl is the start url of your application.

Spectangular.loadPage('/#/start/', 'input#username');

The loadPage function is used for the start page. The browser navigates to the baseUrl and waits on Angular to load the location ('/#/login/').The second argument ('input#username') is a css selector. The browser waits until the web element with this css selector is loaded into the start page. For this example, the browser waits until an input field with id 'username' is loaded on the start page.

Form

Spectangular.form is used for navigation and interaction with form input fields.

CSS selector

The library uses css selectors to find the web elements on the page.

selector: '[name=\"userForm\"]',

The css selector defines an web element with attribute name and value 'userForm'. This element is the container element of the form, which contains all the input fields.

type attribute

The formData variable is a JSON object with the configuration for the formHelper. The type defines the type of input field. The supported type of fields are:

  • textfield
  • textarea
  • selectfield
  • datefield
  • checkbox
  • searchfield

model attribute

The model attribute is the unique ng-model attribute of the field. For example:

<material-input-group ng-model="user.username">   
    <label>Gebruikersnaam</label>   
    <input></input>
</material-input-group>

The userName field has an unique ng-model attribute with value user.username. The e2e test will navigate to the field with the attribute ng-model 'user.username' as css selector.

Important Make sure that each field contains an unique ng-model. If the ng-model is not unique, Selenium will give a warning. For example:

....WARNING - more than one element found for locator By.cssSelector(".checkboxDemo1") - the first result will be used

You cannot use the form but need to use unique css selectors for each field.

For example:

Spectangular.input({selector: '[ng-click=\"showListBottomSheet($event)\"]'}).sendKeys('Hi!');

value attribute

The value attribute is the value the field will have when the test is executed. In this example, the username field will have the value 'admin' and the password field will have the value 'welcome'.

Example 2: table with menu

Open the menu in a table row.

table

Spectangular .table({selector: 'material-gridlist.overview'})

Finds the table with css selector 'material-gridlist.overview'.

getRowMenuButton(0)

.getRowMenuButton(0)

Gets the first row (0) of the table

openAndClickItem({text: 'Update'})

Opens the menu item 'Update' and clicks on the menu item.

Example 3: drawer and tabs

This example opens a drawer, waits until the drawer is visible and switches to a tab 'Out'

whenVisible

WhenVisible uses the [Protractor Expected Conditions] (https://angular.github.io/protractor/#/api?view=ExpectedConditions)