license import { Reporter } from '../reporter.js' ; import { Suite } from '../suite.js' ; import { Test , TestResult } from '../test.js' ; import { IsolatedTestResult } from '../mixins/isolatable.js' ; import { ConditionalTestResult } from '../mixins/conditional.js' ; import { Spec } from '../spec.js' ; export class ConsoleReporter extends Reporter { onSpecStart ( spec , _suite ) { if ( spec . rootTopic != null ) { console . log ( `%c ${ spec . rootTopic ! . description } ` , `background-color: #bef; color: #246;
          font-weight: bold; font-size: 24px;` ) ; } } onTestEnd ( result , test , _suite ) { let resultString ; let resultColor ; if ( result . passed ) { resultString = ' PASSED ' ; resultColor = 'green' ; } else if ( ( result as ConditionalTestResult ) . skipped ) { resultString = ' SKIPPED ' ; resultColor = 'yellow' ; } else { resultString = ' FAILED ' ; resultColor = 'red' ; } const resultLog = [ `${ test . behaviorText }... %c${ resultString }` , `color: #fff; font-weight: bold; background-color: ${ resultColor }` ] ; if ( ( result as IsolatedTestResult ) . isolated ) { resultLog [ 0 ] = `%c ISOLATED %c ${ resultLog [ 0 ] }` ; resultLog . splice ( 1 , 0 , `background-color: #fd0; font-weight: bold; color: #830` , `` ) ; } if ( result . error && ( result . error as any ) . stack ) { console . error ( ( result . error as any ) . stack ) ; } console . log ( ... resultLog ) ; } onUnexpectedError ( message , error , _suite ) { console . error ( message ) ; console . error ( error . stack ) ; } }