From 298759b45e068e83ec3e18c34f003b91c12c4c78 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Tue, 23 Mar 2021 16:08:56 -0400 Subject: [PATCH] fix(amplify-provider-awscloudformation): fix test This test was failing locally because the output contained colors that are not present in the assertion logic. --- .../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({