karma-abe-json2js-preprocessor
A Karma Plugin - Convert JSON files into JS
Installation
Install the plugin from npm:
npm install karma-abe-json2js-preprocessor --save-dev
Example configuration:
// karma.conf.jsmodule { karma;};
Add the json2js
preprocessor and abeJson
as a framework within
your Karma configuration file.
Usage
So you want to incorporate the following json file into your tests:
tests/json/example.json
You can use new AbeJson('json/example.json')
to load that specific file:
;
Note: that we use the parent directory and file name.
API
-
abeJson.get
Returns the json
-
abeJson.example(exampleName)
Returns a specific example
In the case above,
abeJson.example('OK')
-
abeJson.load(file)
Loads in a new json file