HTML フィクスチャ データを JsTestDriver テスト環境にロードしようとしています。jsTestDriver.conf
ファイルが作業ディレクトリの最上位にある場合は動作しますが、サブディレクトリに配置してbasePath
JsTestDriver の機能を使用しようとすると動作しません。誰かがこれを機能させましたか?もしそうなら、私は何を間違っていますか?
最初に動作するディレクトリ構造:
├── fixtures
│ └── fix.html
├── jsTestDriver.conf
├── lib
│ └── JsTestDriver-1.3.5.jar
├── server.sh
├── test
│ └── dom.fixture.test.js
└── test.sh
jsTestDriver.conf は次のようになります。
server: http://localhost:9876
# files in the server section are only added if explicitly asked for
serve:
- fixtures/fix.html
test:
- test/dom.fixture.test.js
timeout: 10
server.sh と test.sh は、それぞれサーバーとテストランナーを呼び出します。
サーバー.sh:
PORT=9876
java -jar lib/JsTestDriver-1.3.5.jar --captureConsole --port $PORT --browser "/usr/bin/firefox;%s,/opt/google/chrome/google-chrome;%s;--allow-file-access-from-files"
test.sh
java -jar lib/JsTestDriver-1.3.5.jar --tests all --captureConsole
そして、次のように dom.fixture.test.js コードにフィクスチャをロードします。
function getFixtureContent() {
var url = '/test/fixtures/fix.html';
var request = new XMLHttpRequest();
request.open('GET', url, false); // synchronous!
request.send(null);
return request.responseText;
}
これにより、fix.html に html が正常に返されます。これを DOM にロードする必要があります。
しかし、jsTestDriver.conf ファイルを conf ディレクトリにプッシュすると、JsTestDriver に組み込まれている jetty サーバーが、絶対パス ( ) を使用せずに fix.html ファイルを見つけることができないようです/test//$HOME/javascript/jstd/fixtures/fix.html
。デフォルトでは、JSTD は、/test
Jetty のルートが jsTestDriver.conf ファイルを配置した場所に相対的であると想定します。おそらく、設定basePath
により、それを変更できるはずです。
失敗する試みは次のとおりです。
jsTestDriver.conf が conf ディレクトリにあることを除いて、ディレクトリ構造は同じです。
├── conf
│ └── jsTestDriver.conf
jsTestDriver.conf 内のパスはすべて、次のディレクトリになるように調整されています。
server: http://localhost:9876
# files in the server section are only added if explicitly asked for
serve:
- ../fixtures/fix.html
test:
- ../test/dom.fixture.test.js
timeout: 10
また、server.sh と test.sh には、次の 2 つのコマンド ライン スイッチが追加されています。
--basePath .. --config conf/jsTestDriver.conf
残りは同じです。
エラーは次のとおりです。
<h2>HTTP ERROR 404</h2>
<p>Problem accessing /test/fixtures/fix.html. Reason:
<pre>NOT_FOUND</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
バージョン 1.3.5 と 1.3.4.b で試しました。同じ結果です。この謎を解く手助けをしてくれる人に感謝します。