From 8a153a83ad47c3950846d4c359544ac8cfb0dfa9 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 30 Jan 2023 17:26:30 +0100 Subject: [PATCH] Improved job manager unit test stability --- ghost/job-manager/test/job-manager.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ghost/job-manager/test/job-manager.test.js b/ghost/job-manager/test/job-manager.test.js index beaaeaeb6f..bee32c7a5f 100644 --- a/ghost/job-manager/test/job-manager.test.js +++ b/ghost/job-manager/test/job-manager.test.js @@ -250,17 +250,17 @@ describe('Job Manager', function () { it('uses worker message handler when job sends a message', async function (){ const workerMessageHandlerSpy = sinon.spy(); const jobManager = new JobManager({workerMessageHandler: workerMessageHandlerSpy}); + const completion = jobManager.awaitCompletion('will-send-msg'); jobManager.addJob({ job: path.resolve(__dirname, './jobs/message.js'), name: 'will-send-msg' }); jobManager.bree.run('will-send-msg'); - + await delay(100); jobManager.bree.workers['will-send-msg'].postMessage('hello from Ghost!'); - // Give time for worker (worker thread) <-> parent process (job manager) communication - await delay(100); + await completion; should(workerMessageHandlerSpy.called).be.true(); should(workerMessageHandlerSpy.args[0][0].name).equal('will-send-msg');