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

mockatenate

v0.1.0

Published

concatenator for JSON mocks

Downloads

25

Readme

Mock concatenate!

Mockatenate is a simple utility script, that i wrote in order to make my life easier while developing with angular

What it does

It recursively reads json files, concatenating them in a single mock file.

For example, if you have a directory structure like the following:

mocks/
  articles/
    64.json
    32.json
  pictures/
    list.json
    34.json

Running mockatenate mocks/ will convert that into a single mock.js file, with the following content:

var mocks = {
  articles: {
    64: {
      <content of mocks/articles/64.json>
    },
    32: {
      <content of mocks/articles/32.json>
    }
  },
  pictures: {
    list: {
      <content of mocks/list.json>
    },
    34: {
      <content of mocks/pictures/34.json>
    }
  }
};

I recommend having a convention for mocks listing all resources of one type, list in this case.

Why is this useful and what has to do with angular?

With angular you can happily do test driven development. One of the things i was not so happy about was the duplication of mocks between unit tests and integration (protractor, end to end) tests.

Furthermore, i had a lot of mocks around and that was cluttering my testing code.

Using mockcatenate, you can keep your mocks clearly readable and accessible in their folders, then include them in your protractor and unit tests, and link them to API endpoints.

How to include the generated mock

At the end you will have a single mock.js file declaring a mocks variable. It just has to be included in your test javascript logic.

  • for unit tests, add it in the karma.conf.js file
  • for integration tests, load the file in your test index.html

How to install

With npm:

$ npm install mockatenate