[英]ElasticSearch Nodejs Express Automated Testing
如何使用Node測試框架實現ElasticSearch的自動化測試?
我想將ElasticSearch實現到我的nodejs項目中以獲得高效的搜索能力,這是使用Express框架,frisby,Socket.io等.ElasticSearch nodejs實現很容易在谷歌上獲得,但不是它的自動化測試。 需要建議。
您可以使用Jasmine或Mocha作為Node.js的測試框架。 在測試套件中,您可以使用另一個庫: superagent 。
Superagent允許您對指定的URL執行HTTP請求。
另一方面,您有一個接收HTTP請求的elasticsearch。
您可以以http請求的形式擁有一個數據庫,以向elasticsearch發布。 每個數據集都適合於提供彈性搜索以檢查測試是否通過。
以下是如何使用superagent向elasticsearch服務器發出請求的示例:
var request = require('superagent');
var should = require('should.js');
describe('Your test suite', function () {
it('Should test elasticsearch search', function (done) {
request.get('http://localhost:9002/index/type/_search')
.end(function (err, res) {
should.not.exist(err);
should.exist(res);
});
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.