简体   繁体   中英

elasticsearch embedded in Node.js

我是Node.js开发的新手,我想知道是否有一种方法可以将ElasticSearch嵌入Node.js应用程序中进行测试,或者是否有另一种方法可以测试与ElasticSearch的交互,而无需运行ElasticSearch实例(mock ?)

There are no existing mock libraries for Elasticsearch and Node at the moment. If you know exactly what queries you are going to be performing, you could use a mocking library to mock the entire ES client and assert simple behaviors.

What I'd recommend, however, is actually running ES in a development environment for testing. I find that mocking external services is a pretty tricky thing to do in general, and your tests will likely be much more robust / trustworthy if running against an actual instance of the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM