@@ -2,6 +2,7 @@ import ansis from 'ansis';
22import cliSpinners from 'cli-spinners' ;
33import logSymbols from 'log-symbols' ;
44import os from 'node:os' ;
5+ import process from 'node:process' ;
56import type { MockInstance } from 'vitest' ;
67import { Logger } from './logger.js' ;
78
@@ -26,6 +27,7 @@ describe('Logger', () => {
2627 let output = '' ;
2728 let consoleLogSpy : MockInstance < unknown [ ] , void > ;
2829 let processStderrSpy : MockInstance < [ ] , typeof process . stderr > ;
30+ let processPlatformSpy : MockInstance < [ ] , typeof process . platform > ;
2931 let performanceNowSpy : MockInstance < [ ] , number > ;
3032 let mathRandomSpy : MockInstance < [ ] , number > ;
3133
@@ -56,6 +58,12 @@ describe('Logger', () => {
5658 processStderrSpy = vi
5759 . spyOn ( process , 'stderr' , 'get' )
5860 . mockReturnValue ( mockProcessStderr as typeof process . stderr ) ;
61+
62+ // ora uses is-unicode-supported to determine if dots or line is default spinner
63+ processPlatformSpy = vi
64+ . spyOn ( process , 'platform' , 'get' )
65+ . mockReturnValue ( 'linux' ) ;
66+ vi . stubEnv ( 'TERM' , 'xterm' ) ;
5967 } ) ;
6068
6169 beforeEach ( ( ) => {
@@ -72,6 +80,7 @@ describe('Logger', () => {
7280 vi . useRealTimers ( ) ;
7381 consoleLogSpy . mockReset ( ) ;
7482 processStderrSpy . mockReset ( ) ;
83+ processPlatformSpy . mockReset ( ) ;
7584 performanceNowSpy . mockReset ( ) ;
7685 mathRandomSpy . mockReset ( ) ;
7786 } ) ;
@@ -308,7 +317,7 @@ ${ansis.magenta('└')} ${ansis.green(`Total line coverage is ${ansis.bold('82%'
308317 await expect ( task ) . resolves . toBeUndefined ( ) ;
309318
310319 expect ( output ) . toBe (
311- `${ logSymbols . success } Uploaded report to portal ${ ansis . gray ( '(42 ms)' ) } \n` ,
320+ `${ ansis . green ( '✔' ) } Uploaded report to portal ${ ansis . gray ( '(42 ms)' ) } \n` ,
312321 ) ;
313322 } ) ;
314323
@@ -322,7 +331,7 @@ ${ansis.magenta('└')} ${ansis.green(`Total line coverage is ${ansis.bold('82%'
322331 await expect ( task ) . rejects . toThrow ( 'GraphQL error: Invalid API key' ) ;
323332
324333 expect ( output ) . toBe (
325- `${ logSymbols . error } Uploading report to portal → ${ ansis . red ( 'Error: GraphQL error: Invalid API key' ) } \n` ,
334+ `${ ansis . red ( '✖' ) } Uploading report to portal → ${ ansis . red ( 'Error: GraphQL error: Invalid API key' ) } \n` ,
326335 ) ;
327336 } ) ;
328337
@@ -361,7 +370,7 @@ ${logSymbols.success} Uploaded report to portal ${ansis.gray('(42 ms)')}
361370
362371 expect ( output ) . toBe (
363372 `
364- ${ logSymbols . error } Uploading report to portal ${ ansis . red . bold ( '[SIGINT]' ) }
373+ ${ ansis . red ( '✖' ) } Uploading report to portal ${ ansis . red . bold ( '[SIGINT]' ) }
365374
366375${ ansis . red . bold ( 'Cancelled by SIGINT' ) }
367376` . trimStart ( ) ,
@@ -417,7 +426,7 @@ ${logSymbols.success} Uploaded report to portal ${ansis.gray('(42 ms)')}
417426
418427 expect ( output ) . toBe (
419428 `
420- ${ logSymbols . error } Uploading report to portal → ${ ansis . red ( 'Error: GraphQL error: Invalid API key' ) }
429+ ${ ansis . red ( '✖' ) } Uploading report to portal → ${ ansis . red ( 'Error: GraphQL error: Invalid API key' ) }
421430 ${ ansis . gray ( 'Sent request to Portal API' ) }
422431 ${ ansis . gray ( 'Received response from Portal API' ) }
423432` . trimStart ( ) ,
@@ -470,7 +479,7 @@ ${logSymbols.error} Uploading report to portal → ${ansis.red('Error: GraphQL e
470479 await expect ( command ) . resolves . toBeUndefined ( ) ;
471480
472481 expect ( output ) . toBe (
473- `${ logSymbols . success } ${ ansis . green ( '$' ) } npx eslint . --format=json ${ ansis . gray ( '(42 ms)' ) } \n` ,
482+ `${ ansis . green ( '✔' ) } ${ ansis . green ( '$' ) } npx eslint . --format=json ${ ansis . gray ( '(42 ms)' ) } \n` ,
474483 ) ;
475484 } ) ;
476485
@@ -489,7 +498,7 @@ ${logSymbols.error} Uploading report to portal → ${ansis.red('Error: GraphQL e
489498 await expect ( command ) . rejects . toThrow ( 'Process failed with exit code 1' ) ;
490499
491500 expect ( output ) . toBe (
492- `${ logSymbols . error } ${ ansis . red ( '$' ) } npx eslint . --format=json\n` ,
501+ `${ ansis . red ( '✖' ) } ${ ansis . red ( '$' ) } npx eslint . --format=json\n` ,
493502 ) ;
494503 } ) ;
495504 } ) ;
0 commit comments