1
REST APIのエンドポイントへの呼び出しがファイルを処理していることを検証したいと考えていますが、どうすればよいかわかりませんが、これについての例はありません。私はdocumentationを見ましたが、これは私にはあまり役に立ちませんでした。REST APIがファイルを提供するようにmocha/chaiを使用していますか?
サーバー側のコードは、基本的に(Expressで)行います
handleRetrieveContent(req, res, next) {
const filepaht = '...';
res.sendFile(filepath)
}
とテストケース:
- :私は基本的に以下のテストをやりたいと思っています
it('Should get a file', (done) => { chai.request(url) .get('/api/exercise/1?token=' + token) .end(function(err, res) { if (err) { done(err); } res.should.have.status(200); // Not sure what the test here should be? res.should.be.json; // TODO get access to saved file and do tests on it }); });
応答がファイルであることを確認する
- 有効なコンテンツ(チェックサムテスト)
助けてください。