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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ng-tester

v9.0.0

Published

A library containing structured, opinionated Angular testing schematics.

Readme

ng-tester npm

ng-tester is an Angular library designed to create structured, opionated spec files for components. It incorporates angular-unit-test-helper to assist with mocking.

Each spec file is created with two subsections:

"DOM Tests"

  • Contains Angular TestBed
  • Designed for tests that check state changes (i.e. fixture.detectChanges()) or require DOM access (i.e. testing UI elements)
  • Runs slower than functional tests (however as of Angular v9, components are no longer recompiled for each test, significantly improving test run speed from previous Angular versions)

"Functional Tests"

  • Designed for functional logic testing
  • Runs faster than "DOM Tests", since the DOM is not created for these tests

Usage

  1. Run npm install -D ng-tester
  2. Navigate to project/directory you'd like to generate spec file
  3. Run ng generate ng-tester:unit

Output

Below is the test.component.spec.ts file generated for the command ng g ng-tester:unit --name=test:

import { ComponentFixture, TestBed, async } from '@angular/core/testing'
import {
  addProperty,
  addPropertyAsBehaviorSubject,
  autoSpyObj,
  createComponentMock,
  getAllFunctions,
  getAllProperties,
  injectClass,
  injectSpy
} from 'angular-unit-test-helper'

import { TestComponent } from './test.component'

describe('TestComponent', () => {
  let component: TestComponent
  // Declare service mocks
  let fakeServiceSpy: jasmine.SpyObj<FakeService>

  beforeEach(() => {
    // Initialize mocked services from actual services
    fakeServiceSpy = autoSpyObj(FakeService)
  })

  describe('DOM Tests', () => {
    let fixture: ComponentFixture<TestComponent>

    beforeEach(async(() => {
      TestBed.configureTestingModule({
        declarations: [TestComponent],
        imports: [],
        providers: [
          // Inject mocked services into TestBed
          { provide: FakeService, useValue: fakeServiceSpy }
        ],
      }).compileComponents()
    }))

    beforeEach(() => {
      // Get injected dependencies from TestBed
      fakeServiceSpy = injectSpy(FakeService)

      fixture = TestBed.createComponent(TestComponent)
      component = fixture.componentInstance
    })

    it('should create', () => {
      fixture.detectChanges()
      expect(component).toBeTruthy()
    })

    it('test goes here', () => {
      // arrange


      // act


      // assert

    })
  })

  describe('Functional Tests', () => {
    beforeEach(() => {
      // Create component instance with mocked services
      component = new TestComponent(fakeServiceSpy)
    })

    it('test goes here', () => {
      // arrange


      // act


      // assert

    })
  })
})

Peer Dependencies

  • @angular/common: >= 9.0.0
  • @angular/core: >= 9.0.0
  • angular-unit-test-helper: >= 9.3.0
  • tslib: >= 1.10.0

Testing Schematic Locally

  1. In ng-tester directory, run npm run package
  2. Navigate to project/directory you'd like to generate spec file
  3. Install .tgz file created in step 1 as a devDependency (i.e. npm i ../ng-tester/dist/ng-tester/ng-tester-9.0.0.tgz -D)
  4. Run ng generate ng-tester:unit