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

npm-registry-mock

v1.3.2

Published

mock the npm registry

Downloads

72,532

Readme

Build Status Dependency Status

#npm-registry-mock

##Mocked Packages

Currently mocked packages are:

underscore at 1.3.1, 1.3.3 and 1.5.1 while version 1.5.1 is the latest in this mocked registry.

request at 0.9.0, 0.9.5 and 2.27.0 while version 2.27.0 is the latest in this mocked registry.

test-package-with-one-dep at 0.0.0, with mocked dependency [email protected].

npm-test-peer-deps at 0.0.0, with a peer dependency on [email protected] and a dependency on [email protected].

test-repo-url-http at 0.0.0

test-repo-url-https at 0.0.1

test-repo-url-ssh at 0.0.1

mkdirp at 0.3.5

optimist at 0.6.0

clean at 2.1.6

async at 0.2.9, 0.2.10

checker at 0.5.1, 0.5.2

##Usage

Installing underscore 1.3.1:

var mr = require("npm-registry-mock")

mr({port: 1331}, function (err, s) {
  npm.load({registry: "http://localhost:1331"}, function () {
    npm.commands.install("/tmp", "[email protected]", function (err) {
      // assert npm behaves right...
      s.close() // shutdown server
    })
  })
})

Defining custom mock routes:

var mr = require("npm-registry-mock")

var customMocks = {
  "get": {
    "/mypackage": [500, {"ente" : true}]
  }
}

mr({port: 1331, mocks: customMocks}, function (err, s) {
  npm.load({registry: "http://localhost:1331"}, function () {
    npm.commands.install("/tmp", "mypackage", function (err) {
      // assert npm behaves right with an 500 error as response...
      s.close() // shutdown server
    })
  })
})

Limit the requests for each route:

mr({
    port: 1331,
    minReq: 1,
    maxReq: 5
  }, function (err, s) {

##Adding a new fixture

Although ideally we stick with the packages already mocked when writing new tests, in some cases it can be necessary to recreate a certain pathological or unusual scenario in the mock registry. In that case you can run

$ ./add-fixture.sh my-weird-package 1.2.3

to add that package to the fixtures directory.

##Breaking Changes for 1.0

  • the callback returns err, server now, instead of just server (https://github.com/npm/npm-registry-mock/issues/20)
  • options must be of type object
  • a "plugin" is injected via options.plugin, not as a mock being a function
  • a plugin does not override the default routes any more