Flush Through node.js or RESTful endpoint

I am trying to write tests for our endpoints and to do so I would like to be able to setup a db configuration and tear it down afterward in order to setup for the next tests.

I have successfully used the flush command through node.js and the RESful endpoint, however I have not found a way to tell when the flush is done. A static 15 second wait works, but that means if it ever takes 16 seconds the tests will fail or we are wasting multiple seconds per setup. I have also tried to query the node.status and wait for it to be changed to ‘healthy’, however this not actually seem to mark that the flush is done - this is demonstrated b/c we still lose about 1/2 of our next test setup that starts right after the flush.

Is there another way that we can flush the db, or verify that a flush is complete and will not destroy the next round of incoming data? Thanks in advance!

FLUSH isn’t a N1QL statement. You’ll have to issue the command via SDK.
See this for guidance: How do I invoke flush()?