refactor: wrap console.warn spy in try/finally for cleanup safety

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
bymyself
2026-05-14 15:23:23 -07:00
parent 98b7934aa5
commit 42500d452e

View File

@@ -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', () => {