@@ -333,10 +333,14 @@ describe('getPluginOptions', () => {
333333} ) ;
334334
335335describe ( 'validateDifferentSourceMapSettings' , ( ) => {
336- const consoleWarnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
336+ let consoleWarnSpy : ReturnType < typeof vi . spyOn > ;
337+
338+ beforeEach ( ( ) => {
339+ consoleWarnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
340+ } ) ;
337341
338342 afterEach ( ( ) => {
339- consoleWarnSpy . mockClear ( ) ;
343+ consoleWarnSpy . mockRestore ( ) ;
340344 } ) ;
341345
342346 it ( 'does not warn when both settings match' , ( ) => {
@@ -350,16 +354,14 @@ describe('validateDifferentSourceMapSettings', () => {
350354 } ) ;
351355
352356 it ( 'warns when settings conflict' , ( ) => {
353- const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
354357 validateDifferentSourceMapSettings ( {
355358 nuxtSettingKey : 'sourcemap.server' ,
356359 nuxtSettingValue : true ,
357360 otherSettingKey : 'nitro.sourceMap' ,
358361 otherSettingValue : false ,
359362 } ) ;
360- expect ( warnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'sourcemap.server' ) ) ;
361- expect ( warnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'nitro.sourceMap' ) ) ;
362- warnSpy . mockRestore ( ) ;
363+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'sourcemap.server' ) ) ;
364+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'nitro.sourceMap' ) ) ;
363365 } ) ;
364366} ) ;
365367
@@ -383,23 +385,20 @@ describe('extractNuxtSourceMapSetting', () => {
383385} ) ;
384386
385387describe ( 'validate sourcemap settings' , ( ) => {
386- const consoleWarnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
387- const consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
388+ let consoleWarnSpy : ReturnType < typeof vi . spyOn > ;
389+ let consoleLogSpy : ReturnType < typeof vi . spyOn > ;
388390
389391 beforeEach ( ( ) => {
390- consoleLogSpy . mockClear ( ) ;
391- consoleWarnSpy . mockClear ( ) ;
392+ consoleWarnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
393+ consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
392394 } ) ;
393395
394396 afterEach ( ( ) => {
395- vi . clearAllMocks ( ) ;
397+ consoleWarnSpy . mockRestore ( ) ;
398+ consoleLogSpy . mockRestore ( ) ;
396399 } ) ;
397400
398401 describe ( 'should handle nitroConfig.rollupConfig.output.sourcemap settings' , ( ) => {
399- afterEach ( ( ) => {
400- vi . clearAllMocks ( ) ;
401- } ) ;
402-
403402 type MinimalNitroConfig = {
404403 sourceMap ?: SourceMapSetting ;
405404 rollupConfig ?: {
@@ -453,17 +452,20 @@ describe('validate sourcemap settings', () => {
453452describe ( 'change Nuxt source map settings' , ( ) => {
454453 let nuxt : { options : { sourcemap : { client : boolean | 'hidden' ; server : boolean | 'hidden' } } } ;
455454 let sentryModuleOptions : SentryNuxtModuleOptions ;
456-
457- const consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
455+ let consoleLogSpy : ReturnType < typeof vi . spyOn > ;
458456
459457 beforeEach ( ( ) => {
460- consoleLogSpy . mockClear ( ) ;
458+ consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
461459
462460 // @ts -expect-error - Nuxt types don't accept `undefined` but we want to test this case
463461 nuxt = { options : { sourcemap : { client : undefined } } } ;
464462 sentryModuleOptions = { } ;
465463 } ) ;
466464
465+ afterEach ( ( ) => {
466+ consoleLogSpy . mockRestore ( ) ;
467+ } ) ;
468+
467469 it . each ( [
468470 { clientSourcemap : false , expectedSourcemap : false , expectedReturn : 'disabled' } ,
469471 { clientSourcemap : 'hidden' , expectedSourcemap : 'hidden' , expectedReturn : 'enabled' } ,
0 commit comments