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

ng-pom-testing

v1.0.117

Published

Utilities for easy DOM testing using the page-object-model pattern

Downloads

3,194

Readme

Introduction

This module compliments Angular Testbed.

ng-pom-testing provides a utility function mergeConfig for re-using Angular Testbed configuration objects, and a utility class POM for implementing the page-object-model pattern. A POM instance runs actions that are defined by a configuration object that you pass to the constructor. The constructor to the POM also accepts a context object that is passed as the first argument to the action functions. Normally, the context will include objects that were generated as part of the Angular Testbed setup -- fixtures, a dom api, and other functions.

The POM abstracts the underlying testing library (testing-library, spectator, or angular testbed) similar to how a test harness implements an api for interacting with a component instance. For example, you may want to define a single action in a test that interacts with more than a single component, or multiple components in succession like launching a modal that solicits user input -- this capability is out-of-scope for test harnesses.

The POM is particurily useful for BDD.

Tools

  1. mergeConfig() - accepts a list of configuration objects. Precedence follows the es6 implementation of Object.assign(). The merge operation is "deep." Arrays are not replaced -- the entries are concatenated.

     console.log(
         mergeConfig(
             { imports: [ReactiveFormsModule]}, 
             { imports: [MaterialModule]}
         )
     )
    
     // {imports: [ReactiveFormsModule, MaterialModule]}
  2. POM - a class for generating a configured POM implementation

    const pom = new POM({ container, detectChanges}, pomConfig);

The POM configuration object defines the actions that can be taken: the steps to be performed.

This example illustrates how to use mergeConfig and POM.

Notes

  • The example implements a counter component.

    The features for the counter are implemented using three user stories. The three user stories are:

    1. The user needs a title
    2. The user needs to be able to increment a counter
    3. The user needs to see a progress control that displays the counter (the progress value). The progress control should only appear if the counter > 0.

Each successive user story adds complexity to the testing requirements.

  • In the 3rd user story, a common configuration object is used when configuring Angular Testbed; the declarations and providers that are unique dependencies for the tested component are specifed in the describe block. You should adopt this pattern for your own project, in order to reduce boilerplate.

This instructional video can help you get started.