I am trying to create a test for my typescript class which reads data from a json file..
readData<T>(filePath: string): Promise<T> {
return Qajax.getJSON(filePath);
}
I am using Jasmine and karma environment for testing. My issue is that even if I add any json files inside the karma, it won't be loaded in chrome launcher
files: [
'libs/angular/angular.js',
'libs/angular/angular-route.js',
'libs/angular/angular-mocks.js',
'libs/collections/collections.js',
'tests/framework/common/app_config.json',
'tests/package.json',
{ pattern: 'libs/qajax/qajax.js', included: false },
{ pattern: 'libs/q/q.js', included: false },
{ pattern: 'tests/framework/**/*.js', included: false },
{ pattern: 'tests/toolpattern/**/*.js', included: false },
{ pattern: 'tests/test-main.js', included: true },
]
As you can see in the above karma config, I have added a file called app_config.json. Now I am trying to read that file from test...
it("read data test.", function (done) {
var promise = configurationAccessorImpl.readData("tests/framework/common/app_config.json");
promise.then(result => {
console.info("Get configuration test - Success.");
}, error => {
console.log(error);
});
});
The test always fails as the json file does not exists..