# fibula

> A **fixtures** framework for Node.js

Latest version **1.4.0** (published 2016-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install fibula
pnpm add fibula
yarn add fibula
bun add fibula
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2016-05-10 |
| First published | 2015-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yorkie Liu |
| Maintainers | yorkie |
| Keywords | test, fixtures, mocha |

## Links

- npm: https://www.npmjs.com/package/fibula
- Repository: https://github.com/weflex/fibula
- Homepage: https://github.com/weflex/fibula#readme
- Issues: https://github.com/weflex/fibula/issues
- npm.io page: https://npm.io/package/fibula

## Dependencies (5)

- [glob](https://npm.io/package/glob.md) ^6.0.1
- [once](https://npm.io/package/once.md) ^1.3.3
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [typify-json](https://npm.io/package/typify-json.md) ^1.1.2
- [es6-promisify](https://npm.io/package/es6-promisify.md) ^3.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2016-05-10
- 1.3.8 — 2016-04-15
- 1.3.7 — 2016-04-15
- 1.3.6 — 2016-04-15
- 1.3.5 — 2016-04-15
- 1.3.4 — 2016-04-15
- 1.3.3 — 2015-12-19
- 1.3.2 — 2015-12-19
- 1.3.1 — 2015-12-12
- 1.3.0 — 2015-12-12
- 1.2.8 — 2015-12-10
- 1.2.7 — 2015-12-10
- 1.2.6 — 2015-12-08
- 1.2.5 — 2015-12-06
- 1.2.4 — 2015-12-06
- … 6 more at https://npm.io/package/fibula/versions

## README

# Fibula.js

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Dependency Status][david-image]][david-url]
[![Downloads][downloads-image]][downloads-url]

A **fixtures** library to integrate with other test frameworks like [mocha](https://mochajs.org). Fibula.js will be helping
you to write your test based on data you defined.

Usually in developing products at [WeFlex](https://github.com/weflex), we borrow the LoopBack, the powerful RESTFul
framework, to build our API service, and making test case in [Mochajs](https://mochajs.org). 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](https://github.com/weflex), from the hell of writing dependencies specs.

## Install

```sh
$ npm install fibula
```

## Usage

See [test/fixtures](test/fixtures) and [test/parallel](test/parallel).

### Write fixtures

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

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

### Using the fixture

```js
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.

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

The above code would output:

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

which is defined at [Write fixtures](#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](test/fixtures/js-file)
to see the usage.

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/fibula.svg?style=flat-square
[npm-url]: https://npmjs.org/package/fibula
[travis-image]: https://img.shields.io/travis/weflex/fibula.js.svg?style=flat-square
[travis-url]: https://travis-ci.org/weflex/fibula.js
[david-image]: http://img.shields.io/david/weflex/fibula.js.svg?style=flat-square
[david-url]: https://david-dm.org/weflex/fibula.js
[downloads-image]: http://img.shields.io/npm/dm/fibula.js.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/fibula.js

---
_Source: https://npm.io/package/fibula · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
