Helper function for Karma that makes reading JSON files easier
bower install karma-json-reader
-
Include karma-json-reader.js in your karma.conf.js.
files = [ ... 'bower_components/karma-read-json/karma-json-reader.js', ... ]
-
Include your JSON data in your karma.conf.js.
files = [ ... { pattern: 'test/data/*.json', watched: true, served: true, included: false }, ... ]
-
Use
KarmaJSONReader
to get your JSON data.var jsonReader = new KarmaJSONReader('path/to/json/files/'); var mockData = jsonReader.readJSON('mockData.json');