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

angular-mocker

v1.0.3

Published

a command line tool that generates mocks for your angular pipes, services, directives and components

Readme

Angular Mocker

a command line tool that generates mocks for your angular pipes, services, directives and components.

Setup and Installation

  1. Install the tool globally

    npm install -g angular-mocker
  2. Exclude mock files for app build using exclude option in tsconfig.app.json

    "exclude": [
      ...
      "**/mocks/**",
      "**/*.mock.ts",
    ]
  3. Include mock files in include option in tsconfig.spec.json.

    "include": [
      ...
      "**/mocks/**",
      "**/*.mock.ts",
    ]
  4. Generate mock files for the whole application. This will also create barrels for each type of mocks: components.mock.ts, pipes.mock.ts, services.mock.ts, directives.mock.ts, service-providers.mock.ts and index.ts.

    mocker --app-dir  ./

Generating mock for single file

This will create mock file for the specified file. Depending on the type of file, corresponding mock content will be generated.

mocker  app.component.ts

Mock Contents

I. Component Mock

import  {  Component  }  from  '@angular/core';

@Component({
 selector: 'componentselector',
 template: '<div>MockComponent</div>'
})
export  class  MockComponent  {}

II. Pipe Mock

import  {  Pipe,  PipeTransform  }  from  '@angular/core';

@Pipe({
 name: 'pipename',
})
export  class  MockPipeNamePipe  implements  PipeTransform  {
 transform(val:  any)  {
   return  val;
 }
}

III. Directive Mock

import  {  Directive  }  from  '@angular/core';
@Directive({
  selector: 'directiveselector',
})
export  class  MockDirectiveNameDirective  {}

IV. Service Mock

export  const  MockServiceNameService = jasmine.createSpyObj('MockServiceNameService', [
  'ServiceMethods1',
  'ServiceMethods2',
  ...
]);

Command Options

|Option| Default | Description| |--|--|--| |--app-dir / --appDir | undefined | If specified, mocker will run in app-wide mode, meaning it will generate mocks for every file with extensions: .component.ts, .pipe.ts, .directive.ts and .services.ts. It will also generate barrel files by default such as mocks/components.mock.ts, mocks/pipes.mock.ts, mocks/services.mock.ts, mocks/service-providers.mock.ts and mocks/index.ts | |--src-dir / --srcDir | src | Points to directory where the app contains its source files. Normally it will be the src folder. | | --force / -f | false | If set to true, it will overwrite content of the path mock file is to be generated. If false it will not overwrite any contents, but if the mock is not yet in the content of existing file, it will append the mock to it.| |--verbose|false|If set to true, it will show warn/error logs that might be helpful for debugging| |--skip-barrel / --skipBarrel|false|If set to true, it will skip creating / overwriting existing barrel files|