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

fixtures-fs

v2.0.0

Published

Create a temporary fs with JSON fixtures

Readme

fixtures-fs

build status Coverage Status Davis Dependency status

NPM

Create a temporary fs with JSON fixtures

Example

var withFixtures = require('fixtures-fs');
var test = require('tape');
var path = require('path');

var myNpmVerify = ...

/*
  this test wants a directory set up with some mock data
  then do asserts against the directory with some code.

  withFixtures creates the file system before your test and 
  tears it down after your test is done.
*/
test('something something npm', withFixtures(__dirname, {
  foo: {
    'package.json': JSON.stringify({
      name: 'foo',
      version: 'bar',
      dependecies: { foobaz: '~1.0.0' }
    }),
    'npm-shrinkwrap.json': JSON.stringify({
      name: 'foo',
      version: 'bar',
      dependencies: {
        foobaz: {
          version: '3.0.0',
          resolved: 'http://npm.registry.org/foobaz/foobaz-3.0.0.tgz'
        }
      }
    })
  }
}, function (assert) {
  myNpmVerify(path.join(__dirname, 'foo'), function (err) {
    assert.equal(err.message, 'shrinkwrap is wrong.');

    assert.end();
  });
}));

example with mocha

var withFixtures = require('fixtures-fs');
var suite = require('mocha').suite;
var test = require('mocha').it;
var assert = require('assert');
var path = require('path');

var myNpmVerify = ...

suite('test npm stuff', function () {
  test('something something npm', withFixtures(__dirname, {
    ...
  }, function (end) {
    myNpmVerify(path.join(__dirname, 'foo'), function (err) {
      assert.equal(err.message, 'shrinkwrap is wrong.');

      end();
    });
  }));
});

Docs

var func = withFixtures(dirname, fixtures, lambda, opts={})

fixtures-fs := (
    dirname: String,
    fixtures: Fixture, 
    lambda: (EndCallback<T>) => void,
    opts?: FsMock
) => (EndCallback<T>) => void

withFixtures takes a dirname, an object of fixtures and an async lambda function

It will run create a file system matching your fixtures before calling your async lambda function and tear down the file system once the lambda finishes.

You can invoke the returned func with a callback or an object with an .end() method.

dirname

This is the directory the fixtures will be written into.

If this directory does not exist, it will be created.

fixtures

fixtures := Object<String, String | Fixture>

The fixtures object has key value pairs where the key is the directory or file name and the value is either a string content of the file or another object that is the content of a directory

lambda

lambda := (Callback<Error, T> | Object & {
    end: Callback<Error, T>
}) => void

The lambda should be an async function that takes either a callback or an object with an .end(err=null) method. This callback / .end() method is intercepted and withFixtures will cleanup the file system before it completes.

opts

opts := { fs: Object, mkdirp: Function, rimraf: Function }

You can pass an optional opts object to customize the file system functions that withFixtures uses. This is useful if you want to withFixtures to write to a non-standard file system like a browser file system, a remote file system or an in memory file system.

func

The func result of the withFixtures() call can be passed directly into the test() function of tape or the test() function of mocha.

When you call func with either a callback or object with an .end() method argument it will create the fixtures, invoke the lambda, tear down the fixtures and then invoke either the callback or .end() method.

Installation

npm install fixtures-fs

Tests

npm test

Contributors

  • Raynos

MIT Licenced