#ElixirLs + VSCode: error when running tests

5 messages · Page 1 of 1 (latest)

woven hemlock
#

Hello! I have a question that is more on the tooling side.
Whenever I try to run a test in the editor (for example, by pressing the "run" green sign to the left of the line number, I receive this error. My tasks are the default auto-generated:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "mix_task",
            "name": "mix (Default task)",
            "request": "launch",
            "projectDir": "${workspaceRoot}"
        },
        {
            "type": "mix_task",
            "name": "mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}",
            "requireFiles": [
                "test/**/test_helper.exs",
                "test/**/*_test.exs"
            ]
        },
    ]
}

How can I run a test inside of the editor? It's much more useful than just running mix test in console =-)

lethal sun
#

And what do you get in the terminal/console?

woven hemlock
#

In the "debug console" I get:

Started ElixirLS Debug Adapter v0.23.0
ElixirLS Debug Adapter built with elixir "1.17.2" on OTP "27"
Running on elixir "1.17.2 (compiled with Erlang/OTP 25)" on OTP "27"
Protocols are not consolidated
Starting debugger in directory: d:\Coding\Elixir\sample_app
Running with MIX_ENV: test MIX_TARGET: host
Compiling 16 files (.ex)
    error: module Plug.Builder is not loaded and could not be found. This may be happening because the module you are trying to load directly or indirectly depends on the current module
    │
  2 │   use Phoenix.Endpoint, otp_app: :sample_app
    │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    │
    └─ lib/sample_app_web/endpoint.ex:2: SampleAppWeb.Endpoint (module)

== Compilation error in file lib/sample_app_web/endpoint.ex ==
** (CompileError) lib/sample_app_web/endpoint.ex: cannot compile module SampleAppWeb.Endpoint (errors have been logged)
    (elixir 1.17.2) expanding macro: Kernel.use/2
    lib/sample_app_web/endpoint.ex:2: SampleAppWeb.Endpoint (module)
    (phoenix 1.7.14) expanding macro: Phoenix.Endpoint.__using__/1
    lib/sample_app_web/endpoint.ex:2: SampleAppWeb.Endpoint (module)
    (elixir 1.17.2) expanding macro: Kernel.use/2
lethal sun
#

Strange. Did you try mix deps.get?

#

If it is missing Plug.Builder, something is very wrong.