From 27030eaae7ad83b32af18aa448743a994eb23d9d Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Thu, 25 Mar 2021 14:40:59 -0400 Subject: [PATCH] fix(amplify-provider-awscloudformation): fix test (#6955) This test was failing locally because the output contained colors that are not present in the assertion logic. Co-authored-by: Colin Ihrig --- .../stack-progress-printer.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/amplify-provider-awscloudformation/src/__tests__/iterative-deployment/stack-progress-printer.test.ts b/packages/amplify-provider-awscloudformation/src/__tests__/iterative-deployment/stack-progress-printer.test.ts index 7e2dfb57199..97ab51c1732 100644 --- a/packages/amplify-provider-awscloudformation/src/__tests__/iterative-deployment/stack-progress-printer.test.ts +++ b/packages/amplify-provider-awscloudformation/src/__tests__/iterative-deployment/stack-progress-printer.test.ts @@ -5,6 +5,21 @@ import columnify from 'columnify'; const printer: IStackProgressPrinter = new StackProgressPrinter(); jest.mock('columnify'); +// Make sure that chalk colors are stripped for the test. +function chalkMock(input) { + if (input instanceof Date) { + return input.toString(); + } + + return input; +} + +jest.mock('chalk', () => ({ + green: jest.fn().mockImplementation(chalkMock), + red: jest.fn().mockImplementation(chalkMock), + reset: jest.fn().mockImplementation(chalkMock), +})); + describe('StackProgressPrinter', () => { test('print events order by Timestamp', () => { printer.addActivity({