# karma-rest-fixtures-preprocessor

> Preprocessor for simplifying testing REST calls by adding json files as fixtures.

Latest version **0.1.0** (published 2015-04-28) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-04-28 |
| First published | 2015-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | WOOLAN |
| Maintainers | woolan |
| Keywords | karma-plugin, karma-preprocessor, angularjs, angular, unit-testing, fixtures, rest |

## Links

- npm: https://www.npmjs.com/package/karma-rest-fixtures-preprocessor
- Repository: https://github.com/WOOLAN/karma-rest-fixtures-preprocessor
- Issues: https://github.com/WOOLAN/karma-rest-fixtures-preprocessor/issues
- npm.io page: https://npm.io/package/karma-rest-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
- [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

- 0.1.0 (latest) — 2015-04-28

## README

# karma-rest-fixtures-preprocessor

> Preprocessor for simplifying testing REST calls by adding json files as fixtures.

## Installation

The easiest way is to keep `karma-rest-fixtures-preprocessor` as a devDependency in your `package.json`.
```json
{
  "devDependencies": {
    "karma": "~0.10",
    "karma-rest-fixtures-preprocessor": "~0.1"
  }
}
```

You can simple do it by:
```bash
npm install karma-rest-fixtures-preprocessor --save-dev
```

## Configuration
```js
// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      'fixtures/*.json': ['rest-fixtures']
    },

    files: [
      'fixtures/*.json',
      '*.js',
      '*.html'
    ],

    restFixturesPreprocessor: {
      // Base path to rest fixtures. Subdirectories will be added to URL path.
      basePath: 'fixtures/',
      // URL prefix
      restPath: '/rest/'
    }
  });
};
```

## How it works

Preprocessor requires .json files and converts them into .js files by storing json data as javascript objects under `__RESTFIXTURES__` namespace.


the following file:
`./fixtures/auth.user-post.json` (or `./fixtures/auth/user-post.json` if you prefer to use subdirectories)
```json
{
    "message": "Success"
}
```
will be accessible in your test environment:
```js
var fixture = __RESTFIXTURES__[0];
fixture // => {"method": "POST", "url": "/rest/auth/user", "response": {"message": "Success"}}
```

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