@@ -116,3 +116,77 @@ test('benchmark warmup with zero value', async () => {
116116 console . log = originalLog
117117 }
118118} )
119+
120+ test ( 'benchmark with print: false option' , async ( ) => {
121+ let callCount = 0
122+ const fn = ( ) => {
123+ callCount ++
124+ }
125+
126+ // Capture console.log output
127+ const originalLog = console . log
128+ let logged = ''
129+ console . log = ( msg ) => {
130+ logged += msg + '\n'
131+ }
132+
133+ try {
134+ await benchmark ( 'test no print' , { print : false , timeout : 10 } , fn )
135+
136+ // Check that no benchmark output was logged
137+ assert . strictEqual ( logged , '' , 'Expected no output when print: false' )
138+ // But the benchmark should still run
139+ assert ( callCount > 0 , `Expected callCount > 0, got ${ callCount } ` )
140+ } finally {
141+ console . log = originalLog
142+ }
143+ } )
144+
145+ test ( 'benchmark with print: true option (explicit)' , async ( ) => {
146+ let callCount = 0
147+ const fn = ( ) => {
148+ callCount ++
149+ }
150+
151+ // Capture console.log output
152+ const originalLog = console . log
153+ let logged = ''
154+ console . log = ( msg ) => {
155+ logged += msg + '\n'
156+ }
157+
158+ try {
159+ await benchmark ( 'test with print' , { print : true , timeout : 10 } , fn )
160+
161+ // Check that benchmark output was logged
162+ assert ( logged . includes ( 'test with print' ) , 'Expected benchmark output when print: true' )
163+ assert ( callCount > 0 , `Expected callCount > 0, got ${ callCount } ` )
164+ } finally {
165+ console . log = originalLog
166+ }
167+ } )
168+
169+ test ( 'benchmark with default print option (should print)' , async ( ) => {
170+ let callCount = 0
171+ const fn = ( ) => {
172+ callCount ++
173+ }
174+
175+ // Capture console.log output
176+ const originalLog = console . log
177+ let logged = ''
178+ console . log = ( msg ) => {
179+ logged += msg + '\n'
180+ }
181+
182+ try {
183+ // Not specifying print option should default to true
184+ await benchmark ( 'test default print' , { timeout : 10 } , fn )
185+
186+ // Check that benchmark output was logged by default
187+ assert ( logged . includes ( 'test default print' ) , 'Expected benchmark output by default' )
188+ assert ( callCount > 0 , `Expected callCount > 0, got ${ callCount } ` )
189+ } finally {
190+ console . log = originalLog
191+ }
192+ } )
0 commit comments