9
9
REPORT_MOCK ,
10
10
reportMock ,
11
11
} from '@code-pushup/test-utils' ;
12
- import { Diff , readJsonFile } from '@code-pushup/utils' ;
12
+ import { Diff , fileExists , readJsonFile } from '@code-pushup/utils' ;
13
13
import { compareReportFiles , compareReports } from './compare' ;
14
14
15
15
describe ( 'compareReportFiles' , ( ) => {
@@ -23,23 +23,40 @@ describe('compareReportFiles', () => {
23
23
) ;
24
24
} ) ;
25
25
26
- it ( 'should create valid reports -diff.json from report.json files' , async ( ) => {
26
+ it ( 'should create valid report -diff.json from report.json files' , async ( ) => {
27
27
await compareReportFiles (
28
28
{
29
29
before : join ( MEMFS_VOLUME , 'source-report.json' ) ,
30
30
after : join ( MEMFS_VOLUME , 'target-report.json' ) ,
31
31
} ,
32
- join ( MEMFS_VOLUME , 'reports-diff. json') ,
32
+ { outputDir : MEMFS_VOLUME , filename : 'report' , format : [ ' json'] } ,
33
33
) ;
34
34
35
35
const reportsDiffPromise = readJsonFile (
36
- join ( MEMFS_VOLUME , 'reports -diff.json' ) ,
36
+ join ( MEMFS_VOLUME , 'report -diff.json' ) ,
37
37
) ;
38
38
await expect ( reportsDiffPromise ) . resolves . toBeTruthy ( ) ;
39
39
40
40
const reportsDiff = await reportsDiffPromise ;
41
41
expect ( ( ) => reportsDiffSchema . parse ( reportsDiff ) ) . not . toThrow ( ) ;
42
42
} ) ;
43
+
44
+ it ( 'should create all diff files specified by persist.format' , async ( ) => {
45
+ await compareReportFiles (
46
+ {
47
+ before : join ( MEMFS_VOLUME , 'source-report.json' ) ,
48
+ after : join ( MEMFS_VOLUME , 'target-report.json' ) ,
49
+ } ,
50
+ { outputDir : MEMFS_VOLUME , filename : 'report' , format : [ 'json' , 'md' ] } ,
51
+ ) ;
52
+
53
+ await expect (
54
+ fileExists ( join ( MEMFS_VOLUME , 'report-diff.json' ) ) ,
55
+ ) . resolves . toBeTruthy ( ) ;
56
+ await expect (
57
+ fileExists ( join ( MEMFS_VOLUME , 'report-diff.md' ) ) ,
58
+ ) . resolves . toBeTruthy ( ) ;
59
+ } ) ;
43
60
} ) ;
44
61
45
62
describe ( 'compareReports' , ( ) => {
0 commit comments