uuid: - value: d5d38a64-f226-42e0-8691-6c1b128435bf langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-05-16T20:12:19+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: "Don't dump. Write a test." created: - value: '2025-05-15T19:54:03+00:00' changed: - value: '2025-05-16T20:12:19+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2025/05/15/dont-dump-write-test langcode: en body: - value: "
How often do you use functions like var_dump
, dump
, dd
or console.log
to debug an issue?
You want to check the type or value of something, so you add the debug code and reload the page.
If you don't resolve it on the first attempt, you change it or add more debugging lines which, hopefully, you'll remember to clean up before committing your code.
This is a time-consuming process, especially if the code you're debugging isn't easy to trigger.
Maybe it only happens when you've submitted a long form, so you need to manually complete the form each time you want to debug it, if certain steps have already happened or the application state is a certain way.
Instead, consider writing an automated test.
They can be run when needed without needing to manually fill in forms or complete complex steps, and become a permanent part of the codebase rather than something that's only added temporarily whilst debugging.
They can be run manually by Developers, automatically in a CI pipeline and serve as documentation and examples.
Don't dump. Test.
P.S. If you want to learn how to write automated tests in Drupal, subscribe to my free 10-day email course.
" format: basic_html processed: "How often do you use functions like var_dump
, dump
, dd
or console.log
to debug an issue?
You want to check the type or value of something, so you add the debug code and reload the page.
If you don't resolve it on the first attempt, you change it or add more debugging lines which, hopefully, you'll remember to clean up before committing your code.
This is a time-consuming process, especially if the code you're debugging isn't easy to trigger.
Maybe it only happens when you've submitted a long form, so you need to manually complete the form each time you want to debug it, if certain steps have already happened or the application state is a certain way.
Instead, consider writing an automated test.
They can be run when needed without needing to manually fill in forms or complete complex steps, and become a permanent part of the codebase rather than something that's only added temporarily whilst debugging.
They can be run manually by Developers, automatically in a CI pipeline and serve as documentation and examples.
Don't dump. Test.
P.S. If you want to learn how to write automated tests in Drupal, subscribe to my free 10-day email course.
" summary: '' field_daily_email_cta: { }