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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-page-object-model

v1.1.1

Published

[![CodeFactor](https://www.codefactor.io/repository/github/FrancescoBorzi/ngx-page-object-model/badge)](https://www.codefactor.io/repository/github/FrancescoBorzi/ngx-page-object-model) [![Actions Status](https://github.com/FrancescoBorzi/ngx-page-object-

Readme

ngx-page-object-model

CodeFactor Actions Status

ngx-page-object-model is a lightweight library designed to simplify writing unit tests for Angular UI Components by leveraging the Page Object Model (POM) design pattern.

By using the Page Object Model design pattern, you can create a new abstraction level and keep your test logic separated from the logic to read and manipulate the DOM.

This library is fully Angular-based and completely testing-framework-agnostic, making it compatible with Jasmine, Jest, Vitest, or any other unit testing framework. It can be used alongside tools like Spectator or as a standalone solution.

Setup

npm install -D ngx-page-object-model

Basic examples

Example of tests without Page Object Model

In this minimalistic example, direct interaction with the DOM happens within the test itself, leading to repetition and more complex code:

beforeEach(async () => {
  // ...
  fixture = TestBed.createComponent(CounterComponent);
});

it('should increase the counter when clicking on the increase button', () => {
  fixture.debugElement.query(By.css(`#increase-btn`)).nativeElement.click();

  expect(fixture.debugElement.query(By.css(`[data-testid="count"]`)).nativeElement.innerHTML).toEqual('1');
});

it('should decrease the counter if the current value is greater than 0 when clicking on the decrease button', () => {
  fixture.debugElement.query(By.css(`#increase-btn`)).nativeElement.click();
  fixture.debugElement.query(By.css(`#increase-btn`)).nativeElement.click();

  fixture.debugElement.query(By.css(`#decrease-btn`)).nativeElement.click();

  expect(fixture.debugElement.query(By.css(`[data-testid="count"]`)).nativeElement.innerHTML).toEqual('1');
});

Example of tests using the Page Object Model

With the Page Object Model pattern, the logic to interact with the DOM is encapsulated within a dedicated page object. This approach makes tests more readable, ensures accurate typing for HTML elements, and reduces code duplication. The page object is simply a class extending PageObjectModel:

import { DebugHtmlElement, PageObjectModel } from 'ngx-page-object-model';

class CounterPage extends PageObjectModel<CounterComponent> {
  getIncreaseButton(): DebugHtmlElement<HTMLButtonElement> {
    return this.getDebugElementByCss('#increase-btn');
  }
  getDecreaseButton(): DebugHtmlElement<HTMLButtonElement> {
    return this.getDebugElementByCss('#decrease-btn');
  }
  getCount(): DebugHtmlElement<HTMLSpanElement> {
    return this.getDebugElementByTestId('count');
  }

  clickIncreaseButton(): void {
    this.getIncreaseButton().nativeElement.click();
  }
  clickDecreaseButton(): void {
    this.getDecreaseButton().nativeElement.click();
  }
}

The test code is now cleaner, more focused, and avoids repetitive DOM manipulation:

beforeEach(async () => {
  // ...
  fixture = TestBed.createComponent(CounterComponent);
  page = new CounterPage(fixture);
});

it('should increase the counter when clicking on the increase button', () => {
  page.clickIncreaseButton();

  expect(page.getCount().nativeElement.innerHTML).toEqual('1');
});

it('should decrease the counter if the current value is greater than 0 when clicking on the decrease button', () => {
  page.clickIncreaseButton();
  page.clickIncreaseButton();

  page.clickDecreaseButton();

  expect(page.getCount().nativeElement.innerHTML).toEqual('0');
});

More developer-friendly errors

When using Angular default methods, running into a typo in a selector usually gives you an error like this:

TypeError: Cannot read properties of null (reading 'nativeElement')

The methods provided by ngx-page-object-model, such as getDebugElementByCss() and getDebugElementByTestId(), are instead designed to produce clearer and more descriptive error messages:

Element with selector "#some-selector" was not found.

This makes debugging a lot smoother, helping you quickly spot and fix broken CSS selectors or incorrect data-testid values.

Expect an element to not be there

If you want to explicitly check that an element is not present in the DOM, you can pass false to disable the default assertion error:

// Assert that the count element is not present in the DOM
expect(page.getCount(false)).not.toBeDefined();

Documentation

  • Check the Documentation for more code examples, features and techniques.