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

seqfixloader

v0.1.1

Published

A YAML FixtureLoader for the Sequelize ORM

Downloads

10

Readme

SeqFixLoader

A YAML "Fixture"-Loader for the Sequilize ORM.

Reasoning

Like writing Integration-Tests? Yeah? Then you may like this tool.

With this Fixture-Loader it gets pretty easy to write dedicated Data for tests and load them in your Mocha-Rundown. Test a piece of code and clean up afterwards or at the beginning of the next test.

On a further note: You may want to virtualize your Project and create a Vagrant Box. For the necessary "base"-hydration of the DB you could use this tool.

Or you could write a script that dumps your existing data to "YAML"-Dumps and load them locally in your dev-env.

Getting Started

Prerequisites

  • Sequilize: ^~4.X

Installing

npm install seqfixloader --save-dev

Setup

For the FixtureLoader to work you need to provide a Sequilize-Instance with the registered Models and your DB-Config. For this you have to edit the provided config.yml in the SRC-Dir of the module-package

As an example:

/src/config.yaml
# You can rename or move the folder within the lib structure
LoaderDir: "./Loader"
FixtureDir: "./Fixture"
# Sequilize Instance which exports an instance with the registered Models
sequilize: "../test/orm.js"
method: "instance"

The "method" provides the actual sequlize instance and should be edited as necessary (it may not be called "instance" in your case)

Using the Fixture Loader

Now you're good to go. Let's assume that you use Mocha.js and Chai for assertion.

Create a YAML-File with your Fixture, like:

# Loader: test.js

- user:
    name: "Test String"
    role: "admin"
    createdAt: "2017-12-12 12:32:23"
    updatedAt: "2017-12-12 12:32:23"

It's is important that the sequilize-model is called the same. In this case: "user".

Create now a Loader for this Fixture-Group. I. e. userFixtureLoader.js

// Fixture Loader for the User Entity

const moment = require('moment');

function supports()
{
    return 'user'
}

function getDefaults()
{
    return {
        name: null,
        role: null,
        createdAt: moment().subtract(1, 'year').format('YYYY-MM-DD HH:mm:ss'),
        updatedAt: moment().format('YYYY-MM-DD HH:mm:ss')
    }
}

module.exports = {
    supports: supports(),
    getDefaults: getDefaults()
};

A Loader must have the methods: Supports and getDefaults. The Loader is in charge to "normalize" your Fixture to the Model. That means that the "getDeaults" should return the model structure with default values. This saves some time.

The Loader must be named: "entity" (i. e. what the loader Supports) followed by "FixtureLoader". Just have look at the package. There's an example Loader and Fixture.

You could write a test now as follows:

const FixtureLoader = require('seqfixloader');

describe('Something Something', function () {
    it('Should throw an error due to a wrong filepath', function () {
        new FixtureLoader().loadFixture(path.resolve(__dirname, '../src/Fixture/thisIsBullshit.yaml')).catch(output => {
            expect(output).to.be.instanceOf(Error)
        });
    });
});

or if yout want to clean the DB before the test:

const FixtureLoader = require('seqfixloader');
let instance = new FixtureLoader();

instance.cleaner().then(output => {
    instance.loadFixtures();
}).catch(error => {
    console.log(error)
});

Methods

  • loadFixtures(): Loads all fixtures in the configured Folder i. e. '/Fixture'
  • loadFixture(): Loads the File from the provided File-Path
  • cleaner(): Guess what it does?

Dependencies

  • js-yaml: ^3.10.0
  • commander: ^2.12.2