Harrygr

Harrygr

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.
  • The debugger hangs at the end of the test run and has to be manually stopped

I’m using the default config as generated by ElixirLS:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "mix_task",
      "name": "mix test",
      "request": "launch",
      "task": "test",
      "taskArgs": [
        "--trace"
      ],
      "startApps": true,
      "projectDir": "${workspaceRoot}",
      "requireFiles": [
        "test/**/test_helper.exs",
        "test/**/*_test.exs"
      ]
    }
  ]
}

Here’s the output from starting the debugger:

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.?

Showing Posts 1 to 7

Ankit_Lathiya

Ankit_Lathiya

Using Visual Studio Code to debug Jest based unit tests, please follow the below steps.

Setting up configuration

Step 1: Enable debugging in our project.
Step 2: Configuring the ElixirJS test debugging single run.
Step 3: Debugging our project.

Your configuration seems right and I don’t know what version you are using of VSCode but right now the test experience in VSCode with Elixir is good.

Best Regards,

Harrygr

Harrygr OP

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.

axelson

axelson

Scenic Core Team

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

mike_bianco

mike_bianco

I’m running into a similar problem. Would love to understand how others are using elixirls and vscode debugger.

bengro

bengro

Same here. I want to debug the app whilst running a test.

Could anyone share their configuration or at least describe the best possible debugging experience to date? Which IDE, plugins, etc?

Being new to the ecosystem and being used to a super smooth debugging experience (JVM) I’m feeling overwhelmed and underwhelmed at the same time :slight_smile:

peoj

peoj

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:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "mix_task",
      "name": "mix test",
      "request": "launch",
      "task": "test",
      "taskArgs": [],
      "startApps": true,
      "projectDir": "${workspaceRoot}",
      "requireFiles": ["test/**/test_helper.exs", "test/**/*_test.exs"]
    },
    {
      "type": "mix_task",
      "name": "mix test current file",
      "request": "launch",
      "task": "test",
      "taskArgs": [
        "${relativeFile}"
      ],
      "startApps": true,
      "projectDir": "${workspaceRoot}",
      "requireFiles": [
        "test/**/test_helper.exs",
        "${relativeFile}"
      ]
    },
    {
      "type": "mix_task",
      "name": "mix test current line number",
      "request": "launch",
      "task": "test",
      "taskArgs": [
        "${relativeFile}:${lineNumber}"
      ],
      "startApps": true,
      "projectDir": "${workspaceRoot}",
      "requireFiles": [
        "test/**/test_helper.exs",
        "${relativeFile}"
      ]
    }
  ]
}

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?

lukaszsamson

lukaszsamson

ElixirLS Core Team

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

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews