1.4.0 • Published 8 years ago

fibula v1.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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

1.4.0

8 years ago

1.3.8

8 years ago

1.3.7

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.8

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago