Skip to content

Commit df0ec9c

Browse files
author
Michael Hladky
committed
refactor: fix tests
1 parent 1c41694 commit df0ec9c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('runAutorunExecutor', () => {
99
Object.entries(process.env).filter(([k]) => k.startsWith('CP_')),
1010
);
1111
const executeProcessSpy = vi.spyOn(executeProcessModule, 'executeProcess');
12-
let loggerSpy: Awaited<typeof import('@code-pushup/utils')>['logger'];
12+
let logger: import('@code-pushup/utils').Logger;
1313

1414
beforeAll(() => {
1515
Object.entries(process.env)
@@ -24,8 +24,8 @@ describe('runAutorunExecutor', () => {
2424
});
2525

2626
beforeEach(async () => {
27-
const { logger } = await import('@code-pushup/utils');
28-
loggerSpy = logger;
27+
const utils = await import('@code-pushup/utils');
28+
logger = utils.logger;
2929
vi.unstubAllEnvs();
3030
executeProcessSpy.mockResolvedValue({
3131
bin: 'npx ...',
@@ -125,7 +125,7 @@ describe('runAutorunExecutor', () => {
125125
});
126126

127127
expect(output.command).not.toContain('--verbose');
128-
expect(loggerSpy.warn).toHaveBeenCalledTimes(0);
128+
expect(logger.warn).toHaveBeenCalledTimes(0);
129129
});
130130

131131
it('should log env var in dryRun information if verbose is set', async () => {
@@ -140,18 +140,18 @@ describe('runAutorunExecutor', () => {
140140
expect(executeProcessSpy).toHaveBeenCalledTimes(0);
141141

142142
expect(output.command).not.toContain('--verbose');
143-
expect(loggerSpy.warn).toHaveBeenCalledTimes(1);
144-
expect(loggerSpy.warn).toHaveBeenCalledWith(
143+
expect(logger.warn).toHaveBeenCalledTimes(1);
144+
expect(logger.warn).toHaveBeenCalledWith(
145145
expect.stringContaining('CP_VERBOSE="true"'),
146146
);
147147
});
148148

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

152-
expect(loggerSpy.command).toHaveBeenCalledTimes(0);
153-
expect(loggerSpy.warn).toHaveBeenCalledTimes(1);
154-
expect(loggerSpy.warn).toHaveBeenCalledWith(
152+
expect(logger.command).toHaveBeenCalledTimes(0);
153+
expect(logger.warn).toHaveBeenCalledTimes(1);
154+
expect(logger.warn).toHaveBeenCalledWith(
155155
expect.stringContaining('DryRun execution of'),
156156
);
157157
});

0 commit comments

Comments
 (0)