elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.35k stars 7.98k forks source link

[TaskManager] Silent broken test #181847

Closed afharo closed 1 week ago

afharo commented 3 weeks ago

The test below does one assertion that depends on a promise.

https://github.com/elastic/kibana/blob/cb2c9d97b039a495584e6671d2d35009f2a6cde8/x-pack/plugins/task_manager/server/task_scheduling.test.ts#L839-L884

It should be either

// Await expect().resolves
await expect(result).resolves.toEqual({ id: 'v4uuid', state: { foo: 'bar' } });
// or await the promise and expect the result to equal
expect(await result).toEqual({ id: 'v4uuid', state: { foo: 'bar' } }); 

Not awaiting an expect().resolves silently succeeds without performing the assertion.

A good way to validate that the assertion is not being validated is adding expect.assertions(1); inside the test.

In https://github.com/elastic/kibana/pull/181456, I caught the missing await, but the test now fails. I can't find a way to fix it, so I skipped it in that PR and will let the gurus do their magic 😇