@@ -31,8 +31,9 @@ vi.mock('@clack/prompts', () => ({
3131// Mock process.exit to prevent tests from exiting
3232const mockExit = vi . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => undefined as never )
3333
34- // Store original process.version to restore after tests
34+ // Store original process versions to restore after tests
3535const originalProcessVersion = process . version
36+ const originalProcessVersionsNode = process . versions . node
3637
3738describe ( 'nuxt doctor command' , ( ) => {
3839 beforeEach ( ( ) => {
@@ -42,6 +43,10 @@ describe('nuxt doctor command', () => {
4243 // Reset mockCallHook implementation (clearAllMocks only clears history, not implementation)
4344 mockCallHook . mockReset ( )
4445
46+ // Restore process versions in case previous test modified them
47+ Object . defineProperty ( process , 'version' , { value : originalProcessVersion , configurable : true } )
48+ Object . defineProperty ( process . versions , 'node' , { value : originalProcessVersionsNode , configurable : true } )
49+
4550 // Default mock for loadNuxt
4651 mockLoadNuxt . mockResolvedValue ( {
4752 options : {
@@ -161,6 +166,7 @@ describe('nuxt doctor command', () => {
161166 it ( 'should error on Node.js < 18' , async ( ) => {
162167 // Mock Node version < 18
163168 Object . defineProperty ( process , 'version' , { value : 'v16.20.0' , configurable : true } )
169+ Object . defineProperty ( process . versions , 'node' , { value : '16.20.0' , configurable : true } )
164170
165171 mockLoadNuxt . mockResolvedValueOnce ( {
166172 options : {
@@ -184,9 +190,6 @@ describe('nuxt doctor command', () => {
184190
185191 // Node < 18 is an error
186192 expect ( mockExit ) . toHaveBeenCalledWith ( 1 )
187-
188- // Restore original version
189- Object . defineProperty ( process , 'version' , { value : originalProcessVersion , configurable : true } )
190193 } )
191194
192195 it ( 'should warn when prerender routes defined with SSR disabled' , async ( ) => {
@@ -269,6 +272,7 @@ describe('nuxt doctor command', () => {
269272
270273 // Should only call console.log once with valid JSON
271274 expect ( consoleSpy ) . toHaveBeenCalledOnce ( )
275+ expect ( consoleSpy . mock . calls [ 0 ] ) . toBeDefined ( )
272276 const rawOutput = consoleSpy . mock . calls [ 0 ] ! [ 0 ]
273277
274278 // Verify output is valid JSON (no intro/outro pollution)
@@ -294,6 +298,7 @@ describe('nuxt doctor command', () => {
294298 } )
295299
296300 expect ( consoleSpy ) . toHaveBeenCalledOnce ( )
301+ expect ( consoleSpy . mock . calls [ 0 ] ) . toBeDefined ( )
297302 const rawOutput = consoleSpy . mock . calls [ 0 ] ! [ 0 ]
298303 expect ( ( ) => JSON . parse ( rawOutput ) ) . not . toThrow ( )
299304 const output = JSON . parse ( rawOutput )
@@ -331,8 +336,10 @@ describe('nuxt doctor command', () => {
331336 data : undefined ,
332337 } )
333338
339+ expect ( consoleSpy . mock . calls [ 0 ] ) . toBeDefined ( )
334340 const output = JSON . parse ( consoleSpy . mock . calls [ 0 ] ! [ 0 ] )
335341 const testCheck = output . find ( ( c : any ) => c . name === 'Test' )
342+ expect ( testCheck ) . toBeDefined ( )
336343
337344 // Validate required fields
338345 expect ( testCheck ) . toHaveProperty ( 'name' )
0 commit comments