I’m trying to set up a nice debugging experience in my pretty bog-standard Phoenix app using VSCode and ElixirLS. Currently it kind of works but there are a number of issues with it:
The tests run very slowly compared to mix test (221s vs 7s)
The debugger output is very noisy and interspersed with errors that don’t arise during a normal test run.
Started ElixirLS debugger v0.5.0
Elixir version: "1.10.3 (compiled with Erlang/OTP 22)"
Erlang version: "23"
ElixirLS compiled with Elixir 1.7.4 and erlang 20
# lots of Bcrypt errors 🤷♂️
I’d also like to be able to only run tests for the current file, or even just the current test. I believe vscode exposes various interpolations for launch configs.
Has anyone managed to get a nice test debugging experience in vscode with Elixir? Are there any changes I can make to fix the above problems.?
I’m not sure you understood my question. It has nothing to do with Jest or JavaScript. These are Elixir tests that use ExUnit. The steps you mention don’t explain anything either.
It is expected to be significantly slower since in debugging mode all of the modules in the application need to be instrumented to accept breakpoints.
it’s not too surprising that some test would fail since the previously mentioned debugging delay could cause some GenServer.call’s to fail due to timeouts. Although I generally wouldn’t expect too many issues from this.
This is expected
I’m not sure of a nice way of doing this but you might be able to manually edit the "task": "test", line to have the line number of the test to run. Something like: "task": "test test/providers/workspace_symbols_test.exs:37",. But as you mention some sort of interpolation should be possible, maybe you can find some ideas this VSCode testing extention: Elixir Test - Visual Studio Marketplace
Could you say a bit more as to why please? Is there a way to modify this behaviour?
Here’s an example that works, although the by line test is a bit less convenient since your cursor must be on the precise line of the test you want to run:
Any thoughts on how we might be able to speed this up? Some performance degradation is fine (and I imagine unavoidable) but it’s incredibly slow to use at the moment, and often quicker to add a few IO.inspect statements. Perhaps there is a way of specifying only certain modules that we’re interested in instrumenting?
With VSCode ElixirLS extension it’s now possible to debug test directly from Testing tab or via right clicking the icon next to test definition and selecting Debug test. It will run the debugger with a launch configuration for mix test task and fall back to a default one if not found