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

fibula

v1.4.0

Published

A **fixtures** framework for Node.js

Downloads

31

Readme

Fibula.js

NPM version Build status Dependency Status Downloads

A fixtures library to integrate with other test frameworks like mocha. Fibula.js will be helping you to write your test based on data you defined.

Usually in developing products at WeFlex, we borrow the LoopBack, the powerful RESTFul framework, to build our API service, and making test case in Mochajs. With growing up of our bussiness logic, the more we write, the more complcate we have test cases, and especially some of test case is not idempotent and not indenpendent.

So Fubila.js saved us, the WeFlex team, from the hell of writing dependencies specs.

Install

$ npm install fibula

Usage

See test/fixtures and test/parallel.

Write fixtures

Write the below as our first fixture named as "name/model1.json"

{
  "adapter": "mongo",
  "data": [
    {
      "name": "bar"
    },
    {
      "name": "foo"
    }
  ]
}

Using the fixture

fixtures.use('case1');

Then you will get the data in your database.

If you want to access to variables which you puts to databases, then you should use fixture.get instead of loading them manually.

const data = fixtures.get('model1');
console.log(data);

The above code would output:

[
  {
    "name": "bar"
  },
  {
    "name": "foo"
  }
]

which is defined at Write fixtures by us.

Async method

Calling fixtures.use in above way will do actions with adapters like MongoDB in a blocking way, that means you will need more time to complete your operations. To address this problem, Fibula.js as well as provides non-blocking method.

An example to show how non-blocking code works with Mocha or Jasmine:

beforeEach(function (next) {
  fixtures.use('case1', next);
});

As the above lines looks, you should pass a callback as 2nd of .use arguments, but in async mode, developers should take more care of stuffs in concurrent.

Typed fixture

Usually the fixutures seems to be consist of .json files, namely only string can be defined. Fibula.js as well as supports a flexible to let you define types by parsing .js file. see test/fixtures/js-file to see the usage.

License

MIT