From 42500d452e026f36465778ed2ae09b7ec7b7697f Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 14 May 2026 15:23:23 -0700 Subject: [PATCH] refactor: wrap console.warn spy in try/finally for cleanup safety Co-Authored-By: Claude Opus 4.5 --- src/schemas/nodeDef/migration.test.ts | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/schemas/nodeDef/migration.test.ts b/src/schemas/nodeDef/migration.test.ts index 937a636644..1eee9a07c7 100644 --- a/src/schemas/nodeDef/migration.test.ts +++ b/src/schemas/nodeDef/migration.test.ts @@ -634,29 +634,30 @@ describe('ComfyNodeDefImpl', () => { it('should emit deprecation warning for optional input with defaultInput', () => { const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) + try { + new ComfyNodeDefImpl({ + name: 'TestNode', + display_name: 'Test Node', + category: 'Test', + python_module: 'test_module', + description: 'A test node', + input: { + optional: { + seed: ['INT', { defaultInput: true }] + } + }, + output: [], + output_is_list: [], + output_name: [], + output_node: false + } as ComfyNodeDefV1) - new ComfyNodeDefImpl({ - name: 'TestNode', - display_name: 'Test Node', - category: 'Test', - python_module: 'test_module', - description: 'A test node', - input: { - optional: { - seed: ['INT', { defaultInput: true }] - } - }, - output: [], - output_is_list: [], - output_name: [], - output_node: false - } as ComfyNodeDefV1) - - expect(warnSpy).toHaveBeenCalledWith( - 'Use of defaultInput on optional input test_module:TestNode:seed is deprecated and ignored. Remove defaultInput. Use forceInput only if you intentionally want a socket-only input.' - ) - - warnSpy.mockRestore() + expect(warnSpy).toHaveBeenCalledWith( + 'Use of defaultInput on optional input test_module:TestNode:seed is deprecated and ignored. Remove defaultInput. Use forceInput only if you intentionally want a socket-only input.' + ) + } finally { + warnSpy.mockRestore() + } }) it('should not mutate the original node definition', () => {