@@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
44import { PortalUploadArgs , uploadToPortal } from '@code-pushup/portal-client' ;
55import { collectAndPersistReports } from '@code-pushup/core' ;
66import { MINIMAL_REPORT_MOCK } from '@code-pushup/testing-utils' ;
7+ import { objectToCliArgs } from '@code-pushup/utils' ;
78import { DEFAULT_CLI_CONFIGURATION } from '../../../mocks/constants' ;
89import { yargsCli } from '../yargs-cli' ;
910import { yargsAutorunCommandObject } from './autorun-command' ;
@@ -16,6 +17,21 @@ vi.mock('@code-pushup/core', async () => {
1617 } ;
1718} ) ;
1819
20+ const cli = ( options = { } ) =>
21+ yargsCli (
22+ objectToCliArgs ( {
23+ _ : 'autorun' ,
24+ verbose : true ,
25+ config : '/test/code-pushup.config.ts' ,
26+ 'persist.outputDir' : '/test' ,
27+ ...options ,
28+ } ) ,
29+ {
30+ ...DEFAULT_CLI_CONFIGURATION ,
31+ commands : [ yargsAutorunCommandObject ( ) ] ,
32+ } ,
33+ ) ;
34+
1935describe ( 'autorun-command' , ( ) => {
2036 beforeEach ( ( ) => {
2137 vol . fromJSON (
@@ -28,19 +44,9 @@ describe('autorun-command', () => {
2844 } ) ;
2945
3046 it ( 'should call collect and upload with correct parameters' , async ( ) => {
31- await yargsCli (
32- [
33- 'autorun' ,
34- '--verbose' ,
35- '--config=/test/code-pushup.config.ts' ,
36- '--persist.filename=my-report' ,
37- '--persist.outputDir=/test' ,
38- ] ,
39- {
40- ...DEFAULT_CLI_CONFIGURATION ,
41- commands : [ yargsAutorunCommandObject ( ) ] ,
42- } ,
43- ) . parseAsync ( ) ;
47+ await cli ( {
48+ 'persist.filename' : 'my-report' ,
49+ } ) . parseAsync ( ) ;
4450
4551 expect ( bundleRequire ) . toHaveBeenCalledWith ( {
4652 format : 'esm' ,
0 commit comments