From 2e774778bdb7467f7f2df8ea2a3911c1d530ec79 Mon Sep 17 00:00:00 2001 From: streamich Date: Wed, 19 Feb 2020 13:37:37 +0100 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20make=20tests=20less=20fl?= =?UTF-8?q?aky?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #57823 --- src/plugins/expressions/common/execution/execution.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/expressions/common/execution/execution.test.ts b/src/plugins/expressions/common/execution/execution.test.ts index eeb1ed80e8d0d..b6c1721e33eef 100644 --- a/src/plugins/expressions/common/execution/execution.test.ts +++ b/src/plugins/expressions/common/execution/execution.test.ts @@ -336,16 +336,18 @@ describe('Execution', () => { }); test('execution state is "pending" while execution is in progress', async () => { + jest.useFakeTimers(); const execution = createExecution('sleep 20'); execution.start(null); - await new Promise(r => setTimeout(r, 5)); + jest.advanceTimersByTime(5); expect(execution.state.get().state).toBe('pending'); + jest.useRealTimers(); }); test('execution state is "result" when execution successfully completes', async () => { const execution = createExecution('sleep 1'); execution.start(null); - await new Promise(r => setTimeout(r, 30)); + await execution.result; expect(execution.state.get().state).toBe('result'); });