@@ -123,60 +123,59 @@ describe('knipReporter', () => {
123123 'jsonc-eslint-parser' : {
124124 type : 'unlisted' ,
125125 symbol : 'jsonc-eslint-parser' ,
126- filePath : expect . stringContaining ( 'package.json' )
126+ filePath : expect . pathToEndWith ( 'package.json' )
127127 } ,
128128 } ,
129129 } ) ;
130130 expect ( rawKnipReport . counters ) . toStrictEqual ( { files : 1 , unlisted : 1 } ) ;
131131 } ) ;
132- } ) ;
133132
134- it ( 'should log if custom reporter option verbose is true' , async ( ) => {
135- const reporterOptions : CustomReporterOptions = {
136- verbose : true ,
137- outputFile : KNIP_REPORT_NAME ,
138- rawOutputFile : KNIP_RAW_REPORT_NAME ,
139- } ;
140- await expect (
141- knipReporter ( {
142- report : { files : true } ,
143- issues : { files : new Set ( [ 'main.js' ] ) } ,
144- options : JSON . stringify ( reporterOptions ) ,
145- } as ReporterOptions ) ,
146- ) . resolves . toBeUndefined ( ) ;
147-
148- expect ( logger . info ) . toHaveBeenCalledTimes ( 3 ) ;
149- expect ( logger . info ) . toHaveBeenNthCalledWith (
150- 1 ,
151- `Reporter called with options: ${ JSON . stringify (
152- reporterOptions ,
153- null ,
133+ it ( 'should log if custom reporter option verbose is true' , async ( ) => {
134+ const reporterOptions : CustomReporterOptions = {
135+ verbose : true ,
136+ outputFile : KNIP_REPORT_NAME ,
137+ rawOutputFile : KNIP_RAW_REPORT_NAME ,
138+ } ;
139+ await expect (
140+ knipReporter ( {
141+ report : { files : true } ,
142+ issues : { files : new Set ( [ 'main.js' ] ) } ,
143+ options : JSON . stringify ( reporterOptions ) ,
144+ } as ReporterOptions ) ,
145+ ) . resolves . toBeUndefined ( ) ;
146+
147+ expect ( logger . info ) . toHaveBeenCalledTimes ( 3 ) ;
148+ expect ( logger . info ) . toHaveBeenNthCalledWith (
149+ 1 ,
150+ `Reporter called with options: ${ JSON . stringify (
151+ reporterOptions ,
152+ null ,
153+ 2 ,
154+ ) } `,
155+ ) ;
156+ expect ( logger . info ) . toHaveBeenNthCalledWith (
154157 2 ,
155- ) } `,
156- ) ;
157- expect ( logger . info ) . toHaveBeenNthCalledWith (
158- 2 ,
159- `Saved raw report to ${ reporterOptions . rawOutputFile } ` ,
160- ) ;
161- expect ( logger . info ) . toHaveBeenNthCalledWith (
162- 3 ,
163- `Saved report to ${ reporterOptions . outputFile } ` ,
164- ) ;
165- } ) ;
158+ `Saved raw report to ${ reporterOptions . rawOutputFile } ` ,
159+ ) ;
160+ expect ( logger . info ) . toHaveBeenNthCalledWith (
161+ 3 ,
162+ `Saved report to ${ reporterOptions . outputFile } ` ,
163+ ) ;
164+ } ) ;
166165
167- it ( 'should produce valid audit outputs' , async ( ) => {
168- await expect (
169- knipReporter ( rawReport as ReporterOptions ) ,
170- ) . resolves . toBeUndefined ( ) ;
171-
172- const auditOutputsContent = await memfsFs . promises . readFile (
173- 'knip-report.json' ,
174- { encoding : 'utf8' } ,
175- ) ;
176- const auditOutputsJson = JSON . parse (
177- auditOutputsContent . toString ( ) ,
178- ) as AuditOutputs ;
179- expect ( auditOutputsJson ) . toMatchSnapshot ( ) ;
180- } ) ;
166+ it ( 'should produce valid audit outputs' , async ( ) => {
167+ await expect (
168+ knipReporter ( rawReport as ReporterOptions ) ,
169+ ) . resolves . toBeUndefined ( ) ;
170+
171+ const auditOutputsContent = await memfsFs . promises . readFile (
172+ 'knip-report.json' ,
173+ { encoding : 'utf8' } ,
174+ ) ;
175+ const auditOutputsJson = JSON . parse (
176+ auditOutputsContent . toString ( ) ,
177+ ) as AuditOutputs ;
178+ expect ( auditOutputsJson ) . toMatchSnapshot ( ) ;
179+ } )
181180} )
182- ;
181+
0 commit comments