11import { afterAll , afterEach , beforeEach , expect , vi } from 'vitest' ;
22import { executorContext } from '@code-pushup/test-nx-utils' ;
33import { MEMFS_VOLUME } from '@code-pushup/test-utils' ;
4- import { logger } from '@code-pushup/utils' ;
54import * as executeProcessModule from '../../internal/execute-process.js' ;
65import runAutorunExecutor from './executor.js' ;
76
@@ -10,6 +9,7 @@ describe('runAutorunExecutor', () => {
109 Object . entries ( process . env ) . filter ( ( [ k ] ) => k . startsWith ( 'CP_' ) ) ,
1110 ) ;
1211 const executeProcessSpy = vi . spyOn ( executeProcessModule , 'executeProcess' ) ;
12+ let loggerSpy : Awaited < typeof import ( '@code-pushup/utils' ) > [ 'logger' ] ;
1313
1414 beforeAll ( ( ) => {
1515 Object . entries ( process . env )
@@ -23,7 +23,9 @@ describe('runAutorunExecutor', () => {
2323 ) ;
2424 } ) ;
2525
26- beforeEach ( ( ) => {
26+ beforeEach ( async ( ) => {
27+ const { logger } = await import ( '@code-pushup/utils' ) ;
28+ loggerSpy = logger ;
2729 vi . unstubAllEnvs ( ) ;
2830 executeProcessSpy . mockResolvedValue ( {
2931 bin : 'npx ...' ,
@@ -116,18 +118,18 @@ describe('runAutorunExecutor', () => {
116118 expect ( executeProcessSpy ) . toHaveBeenCalledTimes ( 0 ) ;
117119
118120 expect ( output . command ) . not . toContain ( '--verbose' ) ;
119- expect ( logger . warn ) . toHaveBeenCalledTimes ( 1 ) ;
120- expect ( logger . warn ) . toHaveBeenCalledWith (
121+ expect ( loggerSpy . warn ) . toHaveBeenCalledTimes ( 1 ) ;
122+ expect ( loggerSpy . warn ) . toHaveBeenCalledWith (
121123 expect . stringContaining ( 'CP_VERBOSE="true"' ) ,
122124 ) ;
123125 } ) ;
124126
125127 it ( 'should log command if dryRun is set' , async ( ) => {
126128 await runAutorunExecutor ( { dryRun : true } , executorContext ( 'utils' ) ) ;
127129
128- expect ( logger . command ) . toHaveBeenCalledTimes ( 0 ) ;
129- expect ( logger . warn ) . toHaveBeenCalledTimes ( 1 ) ;
130- expect ( logger . warn ) . toHaveBeenCalledWith (
130+ expect ( loggerSpy . command ) . toHaveBeenCalledTimes ( 0 ) ;
131+ expect ( loggerSpy . warn ) . toHaveBeenCalledTimes ( 1 ) ;
132+ expect ( loggerSpy . warn ) . toHaveBeenCalledWith (
131133 expect . stringContaining ( 'DryRun execution of' ) ,
132134 ) ;
133135 } ) ;
0 commit comments