@@ -277,4 +277,45 @@ defmodule NodeJS.Test do
277
277
assert Enum . all? ( results , & match? ( { :ok , "clean output" } , & 1 ) )
278
278
end
279
279
end
280
+
281
+ describe "debug mode" do
282
+ test "handles debug messages without crashing" do
283
+ File . mkdir_p! ( "test/js/debug_test" )
284
+
285
+ File . write! ( "test/js/debug_test/debug_logger.js" , """
286
+ // This file outputs debugging information to stdout
287
+ console.log("Debug message: Module loading");
288
+ console.debug("Debug message: Initializing module");
289
+
290
+ module.exports = function testFunction(input) {
291
+ console.log(`Debug message: Function called with input: ${input}`);
292
+ console.debug("Debug message: Processing input");
293
+
294
+ return `Processed: ${input}`;
295
+ };
296
+ """ )
297
+
298
+ # With debug_mode disabled, function still works despite debug output
299
+ result = NodeJS . call ( "debug_test/debug_logger" , [ "test input" ] )
300
+ assert { :ok , "Processed: test input" } = result
301
+
302
+ # Enable debug_mode to verify it works in that mode too
303
+ original_setting = Application . get_env ( :nodejs , :debug_mode )
304
+ Application . put_env ( :nodejs , :debug_mode , true )
305
+
306
+ # Function still works with debug_mode enabled
307
+ result = NodeJS . call ( "debug_test/debug_logger" , [ "test input" ] )
308
+ assert { :ok , "Processed: test input" } = result
309
+
310
+ # Restore original setting
311
+ if is_nil ( original_setting ) do
312
+ Application . delete_env ( :nodejs , :debug_mode )
313
+ else
314
+ Application . put_env ( :nodejs , :debug_mode , original_setting )
315
+ end
316
+
317
+ # Clean up
318
+ File . rm! ( "test/js/debug_test/debug_logger.js" )
319
+ end
320
+ end
280
321
end
0 commit comments