0

JSON構成ファイルを検証するために、Jasmineテスト(Karmaを使用)を実行しようとしています。理想的には、私のアプリは単純に JSON ファイルを app.js にロードし、解析してサーバー名を確認できるようにします。

私のファイル app-config.json :

{
"api_url" : "server.loc",
"prefix" : "api",
}

私の app.js :

var config = $.getJSON('/js/config/app-conf.json');

var server, prefix;

config.done(function(data) {
    server = data.api_url;
    prefix = data.prefix;
});

私のカルマ-conf.js:

// list of files / patterns to load in the browser
files: [
    'jasmine.js',
    'adapter.js',
    'angular.js',
    'angular-resource.js',
    'angular-route.js',
    'angular-translate.js',
    'angular-cookies.js',
    'angular-mocks.js',
    'jquery.min.js',
    'app.js',
    {pattern: 'scripts/*.js', watched: true, included: true, served: true},
    {pattern: 'tests/unit/*Spec.js', watched: true, included: true, served: true},
    {pattern: 'config/app-conf.json', watched: true, included: false, served: true}
],

テストを開始すると、ブラウザ コンソールに次のメッセージが表示されます。

GET http://localhost:9876/js/config/app-conf.json [HTTP/1.1 404 Not Found 1ms]

助けを求めます:)

4

0 に答える 0