Skip to content

Commit 311679f

Browse files
committed
refactor: fix tests for colored formatting
1 parent e6ac40d commit 311679f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/nx-plugin/src/executors/cli/executor.unit.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { logger } from '@nx/devkit';
22
import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest';
33
import { executorContext } from '@code-pushup/test-nx-utils';
4-
import { MEMFS_VOLUME } from '@code-pushup/test-utils';
4+
import { MEMFS_VOLUME, removeColorCodes } from '@code-pushup/test-utils';
55
import * as executeProcessModule from '../../internal/execute-process.js';
66
import runAutorunExecutor from './executor.js';
77

@@ -128,20 +128,28 @@ describe('runAutorunExecutor', () => {
128128
expect(loggerInfoSpy).toHaveBeenCalledWith(
129129
expect.stringContaining(`Run CLI executor`),
130130
);
131-
expect(loggerInfoSpy).toHaveBeenCalledWith(
132-
expect.stringContaining('Command: npx @code-pushup/cli'),
131+
const logs = loggerInfoSpy.mock.calls.map((call: any) =>
132+
removeColorCodes(call[0]),
133133
);
134+
expect(
135+
logs.some((log: string) =>
136+
log.includes('Command: npx @code-pushup/cli --verbose'),
137+
),
138+
).toBe(true);
134139
});
135140

136141
it('should log command if dryRun is set', async () => {
137142
await runAutorunExecutor({ dryRun: true }, executorContext('utils'));
138143

139144
expect(loggerInfoSpy).toHaveBeenCalledTimes(0);
140145
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
141-
expect(loggerWarnSpy).toHaveBeenCalledWith(
142-
expect.stringContaining(
143-
'DryRun execution of: npx @code-pushup/cli --dryRun',
144-
),
146+
const logs = loggerWarnSpy.mock.calls.map((call: any) =>
147+
removeColorCodes(call[0]),
145148
);
149+
expect(
150+
logs.some((log: string) =>
151+
log.includes('DryRun execution of: npx @code-pushup/cli --dryRun'),
152+
),
153+
).toBe(true);
146154
});
147155
});

0 commit comments

Comments
 (0)