@@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
import { PortalUploadArgs , uploadToPortal } from '@code-pushup/portal-client' ;
5
5
import { collectAndPersistReports } from '@code-pushup/core' ;
6
6
import { MINIMAL_REPORT_MOCK } from '@code-pushup/testing-utils' ;
7
+ import { objectToCliArgs } from '@code-pushup/utils' ;
7
8
import { DEFAULT_CLI_CONFIGURATION } from '../../../mocks/constants' ;
8
9
import { yargsCli } from '../yargs-cli' ;
9
10
import { yargsAutorunCommandObject } from './autorun-command' ;
@@ -16,6 +17,21 @@ vi.mock('@code-pushup/core', async () => {
16
17
} ;
17
18
} ) ;
18
19
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
+
19
35
describe ( 'autorun-command' , ( ) => {
20
36
beforeEach ( ( ) => {
21
37
vol . fromJSON (
@@ -28,19 +44,9 @@ describe('autorun-command', () => {
28
44
} ) ;
29
45
30
46
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 ( ) ;
44
50
45
51
expect ( bundleRequire ) . toHaveBeenCalledWith ( {
46
52
format : 'esm' ,
0 commit comments