Skip to content

Commit 41c900b

Browse files
committed
refactor: fix unit test
1 parent 93d1d40 commit 41c900b

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,25 @@ describe('runAutorunExecutor', () => {
124124

125125
expect(output.command).toMatch('--verbose');
126126
expect(loggerWarnSpy).toHaveBeenCalledTimes(0);
127-
expect(loggerInfoSpy).toHaveBeenCalledTimes(2);
127+
expect(loggerInfoSpy).toHaveBeenCalledTimes(1);
128128
expect(loggerInfoSpy).toHaveBeenCalledWith(
129129
expect.stringContaining(`Run CLI executor`),
130130
);
131-
const logs = loggerInfoSpy.mock.calls.map((call: any) =>
132-
removeColorCodes(call[0]),
133-
);
134-
expect(
135-
logs.some((log: string) =>
136-
log.includes('Command: npx @code-pushup/cli --verbose'),
137-
),
138-
).toBe(true);
139131
});
140132

141-
it('should log command if dryRun is set', async () => {
142-
await runAutorunExecutor({ dryRun: true }, executorContext('utils'));
133+
it('should call executeProcess with dryRun option', async () => {
134+
const output = await runAutorunExecutor(
135+
{ dryRun: true },
136+
executorContext('utils'),
137+
);
143138

144-
expect(loggerInfoSpy).toHaveBeenCalledTimes(0);
145-
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
146-
const logs = loggerWarnSpy.mock.calls.map((call: any) =>
147-
removeColorCodes(call[0]),
139+
expect(output.success).toBe(true);
140+
expect(executeProcessSpy).toHaveBeenCalledWith(
141+
expect.objectContaining({
142+
dryRun: true,
143+
}),
148144
);
149-
expect(
150-
logs.some((log: string) =>
151-
log.includes('DryRun execution of: npx @code-pushup/cli --dryRun'),
152-
),
153-
).toBe(true);
145+
expect(loggerInfoSpy).toHaveBeenCalledTimes(0);
146+
expect(loggerWarnSpy).toHaveBeenCalledTimes(0);
154147
});
155148
});

0 commit comments

Comments
 (0)