我想为我的打字稿类从JSON文件中读取数据创建一个测试..如何从因缘访问JSON文件测试
readData<T>(filePath: string): Promise<T> {
return Qajax.getJSON(filePath);
}
我用的茉莉和因果报应的环境进行测试。我的问题是,即使我添加了因果报应内的任何JSON文件,它不会在Chrome启动
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 },
]
加载,你可以在上面因果报应的配置看,我添加了一个名为app_config.json文件。现在我想读取测试文件...
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);
});
});
为JSON文件不存在的测试总是失败..
主要的问题在这里是JSON文件没有因果报应环境得到加载。当您从Chrome启动器检查源文件时,您看不到文件“/base/tests/framework/common/app_config.json”..所有其他.js文件都可见。 –