bookshelf-fixture-loader
Bookshelf fixtures loader
Last updated 3 years ago by tomi77 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bookshelf-fixture-loader 
SYNC missed versions from official npm registry.

bookshelf-fixture-loader

Bookshelf fixtures loader

Build Status Coverage Status Code Climate dependencies Status devDependencies Status peerDependencies Status Downloads

Installation

npm install bookshelf-fixture-loader --save-dev

Usage

Fixture file format is inspired by Django fixture file format.

fixtures/test.yaml

- id: 2
  model: 'Test'
  fields:
    name: 'test 2'

fixtures/test.json

[
  {
    "id": 1,
    "model": "Test",
    "fields": {
      "name": "test 1"
    }
  }
]

In test file:

var knex = require('knex')({
  client: 'sqlite3',
  connection: {
    filename: ':memory:'
  },
  useNullAsDefault: true
});

var bookshelf = require('bookshelf')(knex);
bookshelf.plugin('registry');

var BookshelfFixtureLoader = require('bookshelf-fixture-loader')(bookshelf, __dirname);

describe('BookshelfFixtureLoader', function() {
  it('should load json file', function() {
    BookshelfFixtureLoader('test.json');

    var Model = bookshelf.model('Test');
    Model.forge({id: 1}).fetch().then(function(row) {
      row.get('name').should.equal('test 1');
    });
  });
});

or define absolute path:

BookshelfFixtureLoader('/path/to/fixtures/test.yaml');

Current Tags

  • 0.3.3                                ...           latest (3 years ago)

8 Versions

  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 1
Last Month 1
Dependencies (3)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |