From 398f4bebebb577c51e6464d304e2d00a47a85b0d Mon Sep 17 00:00:00 2001 From: Daniele Ricci Date: Fri, 17 Mar 2023 17:08:22 +0100 Subject: [PATCH] fixup! fixup! test(cardano-services): waits all the chunks before searching for substrings --- packages/cardano-services/test/cli.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cardano-services/test/cli.test.ts b/packages/cardano-services/test/cli.test.ts index f2a8d0caa9b..d2424a5b888 100644 --- a/packages/cardano-services/test/cli.test.ts +++ b/packages/cardano-services/test/cli.test.ts @@ -131,11 +131,12 @@ const callCliAndAssertExit = ( chunks.push(data.toString()); }); proc.on('exit', (code) => { - if (dataMatchOnError) expect(chunks.join('')).toContain(dataMatchOnError); expect(code).toBe(1); expect(spy).toHaveBeenCalled(); - done(); + if (dataMatchOnError) expect(chunks.join('')).toContain(dataMatchOnError); }); + // Wait for the assertions from the previous exit handler before calling the done callback + proc.on('exit', () => setTimeout(done, 10)); }; describe('CLI', () => {