# karma-fixtures-preprocessor

> Karma plugin that puts the content of fixture files in a __FIXTURES__ global array.

Latest version **1.0.0** (published 2014-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install karma-fixtures-preprocessor
pnpm add karma-fixtures-preprocessor
yarn add karma-fixtures-preprocessor
bun add karma-fixtures-preprocessor
```

## 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.0.0 |
| Published | 2014-06-11 |
| First published | 2014-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | MK Safi |
| Maintainers | msafi |
| Keywords | karma-plugin, karma-preprocessor, angularjs, angular, unit-testing, fixtures |

## Links

- npm: https://www.npmjs.com/package/karma-fixtures-preprocessor
- Repository: https://github.com/AppMatch/karma-fixtures-preprocessor
- Issues: https://github.com/AppMatch/karma-fixtures-preprocessor/issues
- npm.io page: https://npm.io/package/karma-fixtures-preprocessor

## 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
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-06-11

## README

# karma-fixtures-preprocessor

Reads the content of your fixture files and constructs a global array, `__FIXTURES__`, that contains the content of those files.

## Installation

`npm install karma-fixtures-preprocessor --save`

**Note:** Karma will automatically see and include plugins whose names start with `karma-*`. However, it is possible that, in your IDE or console configurations, you're running Karma as a global Node module. In that case, you'll have to install this plugin too globally, i.e `npm install karma-fixtures-preprocessor -g`.

## Configuration

```js
// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'test/fixtures/**/*.json' // The location of your fixture files in relation to this, karma.conf.js, file.
    ],

    preprocessors: {
      'test/fixtures/**/*.json': ['fixtures'] // Again, the location of your fixture files in relation to this, karma.conf.js, file.
    },
  })
}
```

That's all. This plugin doesn't provide any other configurable options.

## How does it work?

The plugin will read the content of each of your fixture files and push its content, as-is, to a global array called `__FIXTURES__`. Because the content is pushed into the array as-is, you have to make sure that whatever is in your fixture files is valid JavaScript value.

We use this plugin in our own AngularJS project at AppAdvice to construct the `__FIXTURES__` array from multiple JSON files. Then in the `specHelper.js` of our Jasmine tests, we do:
 
```js
angular.forEach(__FIXTURES__, function(fixture) {
  $httpBackend['when' + fixture.httpVerb](fixture.url).respond(fixture.response)
})
```

## LICENSE
MIT - Copyright (C) AppAdvice.

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