How to debug tests in Deno on VSCODE
Hello everyone, I am trying to debug a unit test in Deno. I have tried using deno test --inspect-brk and I tried generating a launch.json with the deno extension for vscode. Here is my launch.json
4 Replies
Am I doing something blatantly wrong?
Hello! Debugging tests in Deno using VSCode can be done by integrating the Deno extension with the built-in VSCode debugger. To debug your tests, you should create a
launch.json
configuration that specifies how the debugger should connect to Deno.
Based on the documentation, here's a general guide on how to set up your launch.json
for debugging Deno tests:
1. Go to the Run and Debug panel in VSCode.
2. Click on "create a launch.json
file".
3. Select the Deno option from the available debugger configurations.
The configuration will use the --inspect-wait
flag if the configured Deno version is greater than 1.29, or --inspect-brk
for versions older than 1.29. This ensures that the debugger has a chance to connect to your program and register all the breakpoints specified in the code.
Here's an example of what your launch.json
might look like for debugging tests:
Make sure to replace "runtimeExecutable": "deno"
with the path to your Deno executable if it's not in your system's PATH.
When you run this configuration, it should start the Deno test runner with the --inspect-brk
flag, which will pause execution on the first line of code and wait for the debugger to attach. You can then set breakpoints in your test files, and when you continue execution in the debugger, it will stop at those breakpoints.
Remember to adjust the runtimeArgs
as needed for your specific use case, such as specifying a configfile with
--config
or setting permissions with --allow-*
flags.
If you encounter any issues, make sure that you have the latest version of the Deno extension for VSCode installed, and that your Deno version is up to date. 🦕I've never debugged tests like that. Not sure how to do it. Have you tried
--inspect-wait
instead of --inspect-brk
?
One way it surely works is like this: enable the setting deno.codeLens.test
and a "Debug" option should appear right above the tests in your code