fix(backend-defaults): fix flaky TaskWorker initialDelayDuration test
The "respects initialDelayDuration per worker" test had only a 50ms margin (350ms total sleep vs 300ms initial delay) for the worker to complete its internal DB roundtrips before asserting. Under CI load this frequently wasn't enough. Replace the fixed sleep with waitForExpect, consistent with the rest of the test file. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
@@ -328,8 +328,9 @@ describe.each(databases.eachSupportedId())('TaskWorker, %s', databaseId => {
|
||||
expect(fn1).toHaveBeenCalledTimes(0);
|
||||
await new Promise(resolve => setTimeout(resolve, 250));
|
||||
expect(fn1).toHaveBeenCalledTimes(0);
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
expect(fn1.mock.calls.length).toBeGreaterThan(0);
|
||||
await waitForExpect(() => {
|
||||
expect(fn1.mock.calls.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// Start a second worker and make sure it waits but the first worker still works along
|
||||
const fn2 = jest.fn();
|
||||
|
||||
Reference in New Issue
Block a user