1- import * as utils from './utils' ;
2- import * as reportUtils from '../report/utils' ;
3- import * as mdReportUtils from '../../../assert/utils/md-report' ;
1+ import { generateStdoutReport } from './utils' ;
2+ import { createReducedReport } from '../report/utils' ;
3+ import { generateMdReport } from '../../../assert/utils/md-report' ;
44import { persistFlow } from './persist-flow' ;
55import { writeFile } from '../../../../core/file' ;
66import { log } from '../../../../core/loggin' ;
7- import { ReducedReport } from '../report/types' ;
87
9- import { UserFlow } from '../../../../hacky-things/lighthouse' ;
8+ import type { ReducedReport } from '../report/types' ;
9+ import type { UserFlow } from '../../../../hacky-things/lighthouse' ;
1010
1111jest . mock ( 'node:fs' , ( ) => ( {
1212 existsSync : jest . fn ( ) . mockReturnValue ( true )
@@ -15,7 +15,9 @@ jest.mock('../../../../hacky-things/lighthouse')
1515jest . mock ( '../../../../core/file' ) ;
1616jest . mock ( '../../../../core/loggin' ) ;
1717jest . mock ( './utils' ) ;
18- jest . mock ( '../../../assert/utils/md-report' ) ;
18+ jest . mock ( '../../../assert/utils/md-report' , ( ) => ( {
19+ generateMdReport : jest . fn ( ) . mockReturnValue ( 'Mock Md Report' )
20+ } ) ) ;
1921jest . mock ( '../report/utils' , ( ) => ( {
2022 createReducedReport : jest . fn ( ) ,
2123 toReportName : jest . fn ( ) . mockReturnValue ( 'report' ) ,
@@ -49,7 +51,7 @@ describe('persist flow reports in specified format', () => {
4951 } ) ;
5052
5153 it ( 'should log a report if stdout is passed as format' , async ( ) => {
52- const generateStdoutReportSpy = jest . spyOn ( utils , ' generateStdoutReport' ) . mockReturnValue ( 'Mock stdout report' )
54+ const generateStdoutReportSpy = jest . mocked ( generateStdoutReport ) . mockReturnValue ( 'Mock stdout report' )
5355 await persistFlow ( flow , { outPath : '' , format : [ 'stdout' ] , url : 'mock.com' } ) ;
5456 expect ( generateStdoutReportSpy ) . toHaveBeenCalled ( ) ;
5557 expect ( log ) . toHaveBeenCalledWith ( 'Mock stdout report' ) ;
@@ -91,15 +93,14 @@ describe('persist flow reports in specified format', () => {
9193
9294 it ( 'should extract an md report from the json report if md is given as format' , async ( ) => {
9395 jest . spyOn ( flow , 'createFlowResult' ) . mockResolvedValue ( { mock : 'base for md report' } ) ;
94- const createReducedReportSpy = jest . spyOn ( reportUtils , ' createReducedReport' ) . mockReturnValue ( { mock : 'reduced report' } as any as ReducedReport ) ;
95- const generateMdReportSpy = jest . spyOn ( mdReportUtils , ' generateMdReport' ) ;
96+ const createReducedReportSpy = jest . mocked ( createReducedReport ) . mockReturnValue ( { mock : 'reduced report' } as any as ReducedReport ) ;
97+ const generateMdReportMock = jest . mocked ( generateMdReport ) ;
9698 await persistFlow ( flow , { outPath : '' , format : [ 'md' ] , url : 'mock.com' } ) ;
9799 expect ( createReducedReportSpy ) . toHaveBeenCalledWith ( { mock : 'base for md report' } )
98- expect ( generateMdReportSpy ) . toHaveBeenCalledWith ( { mock : 'reduced report' } ) ;
100+ expect ( generateMdReportMock ) . toHaveBeenCalledWith ( { mock : 'reduced report' } ) ;
99101 } ) ;
100102
101103 it ( 'should save the report in md if md is given as format' , async ( ) => {
102- jest . spyOn ( mdReportUtils , 'generateMdReport' ) . mockReturnValue ( 'Mock Md Report' )
103104 await persistFlow ( flow , { outPath : '' , format : [ 'md' ] , url : 'mock.com' } ) ;
104105 expect ( writeFile ) . toHaveBeenCalledWith ( 'report.md' , 'Mock Md Report' ) ;
105106 } ) ;
0 commit comments