|
1 | 1 | import { logger } from '@nx/devkit'; |
2 | 2 | import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest'; |
3 | 3 | 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'; |
5 | 5 | import * as executeProcessModule from '../../internal/execute-process.js'; |
6 | 6 | import runAutorunExecutor from './executor.js'; |
7 | 7 |
|
@@ -128,20 +128,28 @@ describe('runAutorunExecutor', () => { |
128 | 128 | expect(loggerInfoSpy).toHaveBeenCalledWith( |
129 | 129 | expect.stringContaining(`Run CLI executor`), |
130 | 130 | ); |
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]), |
133 | 133 | ); |
| 134 | + expect( |
| 135 | + logs.some((log: string) => |
| 136 | + log.includes('Command: npx @code-pushup/cli --verbose'), |
| 137 | + ), |
| 138 | + ).toBe(true); |
134 | 139 | }); |
135 | 140 |
|
136 | 141 | it('should log command if dryRun is set', async () => { |
137 | 142 | await runAutorunExecutor({ dryRun: true }, executorContext('utils')); |
138 | 143 |
|
139 | 144 | expect(loggerInfoSpy).toHaveBeenCalledTimes(0); |
140 | 145 | 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]), |
145 | 148 | ); |
| 149 | + expect( |
| 150 | + logs.some((log: string) => |
| 151 | + log.includes('DryRun execution of: npx @code-pushup/cli --dryRun'), |
| 152 | + ), |
| 153 | + ).toBe(true); |
146 | 154 | }); |
147 | 155 | }); |
0 commit comments