@@ -62,16 +62,24 @@ const show_violations = { 'show-uncovered': 'violations' } as CliArguments
6262
6363const context_empty = {
6464 context : {
65- coverage : { } as CoverageResult ,
65+ coverage : {
66+ total_files_found : 7 ,
67+ total_stylesheets : 8 ,
68+ total_lines : 9999 ,
69+ } as CoverageResult ,
70+ duration : 2 ,
6671 } ,
6772}
6873
6974const context_with_failures = {
7075 context : {
76+ duration : 2 ,
7177 coverage : {
7278 line_coverage_ratio : 0.4022222 ,
7379 covered_lines : 10 ,
7480 total_lines : 11 ,
81+ total_files_found : 7 ,
82+ total_stylesheets : 9 ,
7583 coverage_per_stylesheet : [
7684 {
7785 url : 'example.com' ,
@@ -157,7 +165,10 @@ test.describe('only --min-line-coverage', () => {
157165 } ,
158166 } satisfies Report
159167 let result = print ( report , show_none , dependencies )
160- expect ( result ) . toEqual ( [ 'Success: total line coverage is 50.22%' ] )
168+ expect ( result ) . toEqual ( [
169+ 'Finished in 2ms on 7 JSON files containing 8 stylesheets with 9,999 lines of CSS in total.' ,
170+ 'Success: total line coverage is 50.22%' ,
171+ ] )
161172 } )
162173
163174 test ( 'failure' , ( ) => {
@@ -166,7 +177,10 @@ test.describe('only --min-line-coverage', () => {
166177 coverage : {
167178 total_lines : 10_000 ,
168179 covered_lines : 5022 ,
180+ total_files_found : 7 ,
181+ total_stylesheets : 8 ,
169182 } as CoverageResult ,
183+ duration : 2 ,
170184 } ,
171185 report : {
172186 ok : false ,
@@ -176,8 +190,9 @@ test.describe('only --min-line-coverage', () => {
176190 } satisfies Report
177191 let result = print ( report , show_none , dependencies )
178192 expect ( result ) . toEqual ( [
193+ 'Finished in 2ms on 7 JSON files containing 8 stylesheets with 10,000 lines of CSS in total.' ,
179194 'Failed: line coverage is 50.22%% which is lower than the threshold of 1' ,
180- 'Tip: cover 4978 more lines to meet the threshold of 100%' ,
195+ 'Tip: cover 4,978 more lines to meet the threshold of 100%' ,
181196 ] )
182197 } )
183198} )
@@ -194,6 +209,7 @@ test.describe('with --min-file-line-coverage', () => {
194209 } satisfies Report
195210 let result = print ( report , show_none , dependencies )
196211 expect ( result ) . toEqual ( [
212+ 'Finished in 2ms on 7 JSON files containing 8 stylesheets with 9,999 lines of CSS in total.' ,
197213 'Success: total line coverage is 50.22%' ,
198214 'Success: all files pass minimum line coverage of 50.00%' ,
199215 ] )
@@ -210,21 +226,26 @@ test.describe('with --min-file-line-coverage', () => {
210226 } satisfies Report
211227 let result = print ( report , show_none , dependencies )
212228
229+ test ( 'metadata' , ( ) => {
230+ expect ( result [ 0 ] ) . toEqual (
231+ 'Finished in 2ms on 7 JSON files containing 9 stylesheets with 11 lines of CSS in total.' ,
232+ )
233+ } )
213234 test ( 'coverage: pass' , ( ) => {
214- expect ( result [ 0 ] ) . toEqual ( 'Success: total line coverage is 50.22%' )
235+ expect ( result [ 1 ] ) . toEqual ( 'Success: total line coverage is 50.22%' )
215236 } )
216237 test ( 'file-coverage: fail' , ( ) => {
217- expect ( result [ 1 ] ) . toEqual (
238+ expect ( result [ 2 ] ) . toEqual (
218239 'Failed: 1 file does not meet the minimum line coverage of 100% (minimum coverage was 50.00%)' ,
219240 )
220241 } )
221242 test ( 'shows hint to --show=violations' , ( ) => {
222- expect ( result [ 2 ] ) . toEqual (
243+ expect ( result [ 3 ] ) . toEqual (
223244 " Hint: set --show-uncovered=violations to see which files didn't pass" ,
224245 )
225246 } )
226247 test ( 'no files shown' , ( ) => {
227- expect ( result ) . toHaveLength ( 3 )
248+ expect ( result ) . toHaveLength ( 4 )
228249 } )
229250 } )
230251
@@ -240,20 +261,20 @@ test.describe('with --min-file-line-coverage', () => {
240261 let result = print ( report , show_violations , dependencies )
241262
242263 test ( 'coverage: pass' , ( ) => {
243- expect ( result [ 0 ] ) . toEqual ( 'Success: total line coverage is 50.22%' )
264+ expect ( result . at ( - 2 ) ) . toEqual ( 'Success: total line coverage is 50.22%' )
244265 } )
245266 test ( 'file-coverage: fail' , ( ) => {
246- expect ( result [ 1 ] ) . toEqual (
267+ expect ( result . at ( - 1 ) ) . toEqual (
247268 'Failed: 1 file does not meet the minimum line coverage of 100% (minimum coverage was 50.00%)' ,
248269 )
249270 } )
250271 test ( 'does not show hint to --show=violations' , ( ) => {
251- expect ( result [ 2 ] ) . not . toEqual (
272+ expect ( result . at ( - 1 ) ) . not . toEqual (
252273 " Hint: set --show-uncovered=violations to see which files didn't pass" ,
253274 )
254275 } )
255276 test . describe ( 'shows file details' , ( ) => {
256- let lines = result . slice ( 2 )
277+ let lines = result
257278
258279 test ( 'shows header block' , ( ) => {
259280 expect ( lines [ 0 ] ) . toEqual ( '─' . repeat ( 60 ) )
@@ -299,7 +320,10 @@ Tip: cover 11 more lines to meet the file threshold of 100%
299320▌ 17 │ c {
300321▌ 18 │ color: red;
301322▌ 19 │ }
302- ` ,
323+
324+ Finished in 2ms on 7 JSON files containing 9 stylesheets with 11 lines of CSS in total.
325+ Success: total line coverage is 50.22%
326+ Failed: 1 file does not meet the minimum line coverage of 100% (minimum coverage was 50.00%)` ,
303327 )
304328 } )
305329 } )
0 commit comments