1- import { logger } from '@nx/devkit' ;
21import { afterAll , afterEach , beforeEach , expect , vi } from 'vitest' ;
32import { executorContext } from '@code-pushup/test-nx-utils' ;
43import { MEMFS_VOLUME } from '@code-pushup/test-utils' ;
4+ import { logger } from '@code-pushup/utils' ;
55import * as executeProcessModule from '../../internal/execute-process.js' ;
66import runAutorunExecutor from './executor.js' ;
77
88describe ( 'runAutorunExecutor' , ( ) => {
99 const processEnvCP = Object . fromEntries (
1010 Object . entries ( process . env ) . filter ( ( [ k ] ) => k . startsWith ( 'CP_' ) ) ,
1111 ) ;
12- const loggerInfoSpy = vi . spyOn ( logger , 'info' ) ;
13- const loggerWarnSpy = vi . spyOn ( logger , 'warn' ) ;
1412 const executeProcessSpy = vi . spyOn ( executeProcessModule , 'executeProcess' ) ;
1513
1614 beforeAll ( ( ) => {
@@ -37,8 +35,6 @@ describe('runAutorunExecutor', () => {
3735 } ) ;
3836
3937 afterEach ( ( ) => {
40- loggerWarnSpy . mockReset ( ) ;
41- loggerInfoSpy . mockReset ( ) ;
4238 executeProcessSpy . mockReset ( ) ;
4339 } ) ;
4440
@@ -110,24 +106,28 @@ describe('runAutorunExecutor', () => {
110106
111107 it ( 'should set env var information if verbose is set' , async ( ) => {
112108 const output = await runAutorunExecutor (
113- { verbose : true } ,
109+ {
110+ dryRun : true , // here to produce log
111+ verbose : true ,
112+ } ,
114113 { ...executorContext ( 'github-action' ) , cwd : '<CWD>' } ,
115114 ) ;
116- expect ( executeProcessSpy ) . toHaveBeenCalledTimes ( 1 ) ;
115+
116+ expect ( executeProcessSpy ) . toHaveBeenCalledTimes ( 0 ) ;
117117
118118 expect ( output . command ) . not . toContain ( '--verbose' ) ;
119- expect ( loggerWarnSpy ) . toHaveBeenCalledTimes ( 0 ) ;
120- expect ( loggerInfoSpy ) . toHaveBeenCalledWith (
121- expect . stringContaining ( 'CP_VERBOSE=true' ) ,
119+ expect ( logger . warn ) . toHaveBeenCalledTimes ( 1 ) ;
120+ expect ( logger . warn ) . toHaveBeenCalledWith (
121+ expect . stringContaining ( 'CP_VERBOSE=\" true\" ' ) ,
122122 ) ;
123123 } ) ;
124124
125125 it ( 'should log command if dryRun is set' , async ( ) => {
126126 await runAutorunExecutor ( { dryRun : true } , executorContext ( 'utils' ) ) ;
127127
128- expect ( loggerInfoSpy ) . toHaveBeenCalledTimes ( 0 ) ;
129- expect ( loggerWarnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
130- expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
128+ expect ( logger . command ) . toHaveBeenCalledTimes ( 0 ) ;
129+ expect ( logger . warn ) . toHaveBeenCalledTimes ( 1 ) ;
130+ expect ( logger . warn ) . toHaveBeenCalledWith (
131131 expect . stringContaining ( 'DryRun execution of' ) ,
132132 ) ;
133133 } ) ;
0 commit comments