Elasticsearch does not index on time in Jasmine tests

3199 views javascript

I have currently a test suite for my elasticsearch api but it seems that all of the tests run before the results are indexed, what I currently have is.

  const index = `test-${Math.floor(Math.random())}`;
  const client = new elasticsearch.Client({
    host: "localhost:9200",
    log: "trace",
  const body = {...}
  beforeAll(async () => {
    await client.bulk({ body });

  afterAll(async () => {
    await client.indices.delete({

I have used async and await in the past but they do not seem to be working now. How can I make sure that the bulk command runs before the tests?

answered question

1 Answer


Try done() callback passed as parameter into beforeAll. Docs does not really specify it's available for beforeAll(there is an example for beforeEach()) but issue at github ensures it should work for beforeAll() as well.

beforeAll(async (done) => {
    await client.bulk({ body });

posted this

Have an answer?


Please login first before posting an answer.