I am having great trouble to get Karma to serve json files that are needed in my application. I don't want to mock the json, I just need it to be served on the karma server.
When I check in the Karma browser, I can load the HTML files in the template folder just fine. But the JSON files in the data folder are not found.
But I have configured both folders in the exact same way!
I tried to add the fixture plugin, but it has no effect on JSON files being served.
My Karma configuration:
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [
'jasmine-jquery',
'jasmine',
'requirejs',
'fixture'
],
// list of files / patterns to load in the browser
files: [
//frontend
{pattern: 'frontend/js/*.js', watched: true, served: true, included: false},
{pattern: 'frontend/templates/*.*', watched: true, served: true, included: false},
{pattern: 'frontend/data/*.json', watched: true, served: true, included: false},
{pattern: 'test/**/*Spec.js', watched: true, included: false},
//'test/helpers/jasmine-jquery.js',
'test/helpers/jasmine-ajax-helper.js',
'test/test-main.js'
],
proxies: {
"/templates/": "/base/frontend/templates/",
"/base/../templates/": "/base/frontend/templates/",
"/data/": "/base/frontend/data/",
"/base/../data/": "/base/frontend/data/"
},
preprocessors: {
'**/*.json' : ['json_fixtures']
},
jsonFixturesPreprocessor: {
variableName: '__json__'
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
logLevel: config.LOG_WARN,
autoWatch: true,
browsers: [
'Firefox'
],
singleRun: false,
});//config.set
};//module.exports
One of my application's requireJS modules loads a JSON files:
define([
"text!../data/mydata.json"
], function (crowdUI, jsonDATA) {//prerequisites
'use strict';
fields = JSON.parse(jsonDATA);
});