karma-gb-json2js-preprocessor
Preprocessor for converting JSON files to AngularJS constants.
Installation
The easiest way is to keep karma-gb-json2js-preprocessor
as a devDependency in your package.json
. You can simple do it by:
npm install karma-gb-json2js-preprocessor --save-dev
Configuration
// karma.conf.jsmodule { config;};
How does it work ?
This preprocessor converts JSON files into Angular constants and puts them in separate Angular modules; each named the same as the source JSON file and generates Angular modules.
For instance this test/fixture/loginService-mocks.json
...
... with the configuration given above will be converted into:
angular;
Inject json fixture into your test case:
;
Contributing
Before sending a pull request, run grunt
in terminal to make sure all tests pass. To continuously run tests during development, run karma start
.
For more information on Karma see the homepage.