11const util = require ( 'util' )
2- const chalk = require ( 'chalk' )
2+
3+ const chalk = {
4+ red : ( str ) => `\u001B[31m${ str } \u001B[39m` ,
5+ gray : ( str ) => `\u001B[90m${ str } \u001B[39m` ,
6+ white : ( str ) => `\u001B[37m${ str } \u001B[39m` ,
7+ bold : ( str ) => `\u001B[1m${ str } \u001B[22m` ,
8+ }
39
410const defaultErrorMessage = ( methodName , bold ) =>
511 `Expected test not to call ${ bold ( `console.${ methodName } ()` ) } .\n\n` +
@@ -40,15 +46,18 @@ const init = ({
4046 throw new Error ( `${ message } \n\n${ messages . join ( '\n\n' ) } ` )
4147 }
4248 }
43- const groups = [ ] ;
49+ const groups = [ ]
4450
4551 const patchConsoleMethod = ( methodName ) => {
4652 const unexpectedConsoleCallStacks = [ ]
4753
4854 const captureMessage = ( format , ...args ) => {
4955 const message = util . format ( format , ...args )
5056
51- if ( silenceMessage && silenceMessage ( message , methodName , { group : groups [ groups . length - 1 ] , groups } ) ) {
57+ if (
58+ silenceMessage &&
59+ silenceMessage ( message , methodName , { group : groups [ groups . length - 1 ] , groups } )
60+ ) {
5261 return
5362 }
5463
@@ -57,7 +66,10 @@ const init = ({
5766 // Don't throw yet though b'c it might be accidentally caught and suppressed.
5867 const { stack } = new Error ( )
5968 if ( stack ) {
60- unexpectedConsoleCallStacks . push ( [ stack . substr ( stack . indexOf ( '\n' ) + 1 ) , [ ...groups , message ] . join ( '\n' ) ] )
69+ unexpectedConsoleCallStacks . push ( [
70+ stack . substr ( stack . indexOf ( '\n' ) + 1 ) ,
71+ [ ...groups , message ] . join ( '\n' ) ,
72+ ] )
6173 }
6274 }
6375
@@ -97,10 +109,10 @@ const init = ({
97109
98110 return false
99111 }
100- let shouldSkipTest ;
112+ let shouldSkipTest
101113
102114 beforeEach ( ( ) => {
103- shouldSkipTest = canSkipTest ( ) ;
115+ shouldSkipTest = canSkipTest ( )
104116 if ( shouldSkipTest ) return
105117
106118 console [ methodName ] = newMethod // eslint-disable-line no-console
0 commit comments