@@ -116,28 +116,37 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
116116 . join ( '\n' ) } `
117117 ) ;
118118
119+ const type = methodName === 'log' ? 'log' : 'warning' ;
119120 const message =
120121 `Expected test not to call ${ chalk . bold (
121122 `console.${ methodName } ()`
122123 ) } .\n\n` +
123- ' If the warning is expected, test for it explicitly by:\n' +
124+ ` If the ${ type } is expected, test for it explicitly by:\n` +
124125 `1. Using the ${ chalk . bold ( '.' + expectedMatcher + '()' ) } ` +
125126 `matcher, or...\n` +
126127 `2. Mock it out using ${ chalk . bold (
127128 'spyOnDev'
128129 ) } (console, '${ methodName } ') or ${ chalk . bold (
129130 'spyOnProd'
130- ) } (console, '${ methodName } '), and test that the warning occurs.`;
131+ ) } (console, '${ methodName } '), and test that the ${ type } occurs.`;
131132
132133 throw new Error ( `${ message } \n\n${ messages . join ( '\n\n' ) } ` ) ;
133134 }
134135 } ;
135136
136137 const unexpectedErrorCallStacks = [ ] ;
137138 const unexpectedWarnCallStacks = [ ] ;
139+ const unexpectedLogCallStacks = [ ] ;
138140
139141 const errorMethod = patchConsoleMethod ( 'error' , unexpectedErrorCallStacks ) ;
140142 const warnMethod = patchConsoleMethod ( 'warn' , unexpectedWarnCallStacks ) ;
143+ let logMethod ;
144+
145+ // Only assert console.log isn't called in CI so you can debug tests in DEV.
146+ // The matchers will still work in DEV, so you can assert locally.
147+ if ( process . env . CI ) {
148+ logMethod = patchConsoleMethod ( 'log' , unexpectedLogCallStacks ) ;
149+ }
141150
142151 const flushAllUnexpectedConsoleCalls = ( ) => {
143152 flushUnexpectedConsoleCalls (
@@ -152,13 +161,25 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
152161 'toWarnDev' ,
153162 unexpectedWarnCallStacks
154163 ) ;
164+ if ( logMethod ) {
165+ flushUnexpectedConsoleCalls (
166+ logMethod ,
167+ 'log' ,
168+ 'toLogDev' ,
169+ unexpectedLogCallStacks
170+ ) ;
171+ unexpectedLogCallStacks . length = 0 ;
172+ }
155173 unexpectedErrorCallStacks . length = 0 ;
156174 unexpectedWarnCallStacks . length = 0 ;
157175 } ;
158176
159177 const resetAllUnexpectedConsoleCalls = ( ) => {
160178 unexpectedErrorCallStacks . length = 0 ;
161179 unexpectedWarnCallStacks . length = 0 ;
180+ if ( logMethod ) {
181+ unexpectedLogCallStacks . length = 0 ;
182+ }
162183 } ;
163184
164185 beforeEach ( resetAllUnexpectedConsoleCalls ) ;
0 commit comments