What's New in IntelliJ Elixir 10.4.0

Person running uphill
Elle Imhoff

Engineer

Elle Imhoff

IntelliJ Elixir, the Elixir plugin for JetBrains IDEs (IntelliJ IDEA, RubyMine, WebStorm, etc), version 10.4.0 has been released. Let’s see what’s new.

ESpec Test Runner

IntelliJ Elixir had a mix test (ExUnit) runner when Jake Becker added it for v4.7.0 (released 2016-12-06). It has seen numerous improvements, such as graphical debugging also by Jake Becker for v5.1.0 (released 2017-04-23). (Jake Becker went on to start the Elixir Language Server.) I rewrote configurations to expand beyond mix and mix test to iex, elixir, and iex -S mix for v8.0.0 (released 2018-08-16).

However, in all these improvements and iterations, the specialized Run configurations have never expanded beyond support for what comes with Elixir: elixir, iex, mix, and ExUnit. That changes with 10.4.0. Alex Dukhno, has added an ESpec test runner. I’ll let him describe how he did it:

I know that copy-paste is not the best strategy… but:

  • Today is my first day when I read and try to understand Kotlin
  • Today is my first day when I try to develop IntelliJ IDEA plugin
  • Today is my second day when I try to use espec

Alex Dukhno describes how he added support for ESpec

The secret of IDE and editor plugin development in general is, this is how it is done. We find something that is similar to what we want to do and we adapt it to our needs and get it working locally. So thanks, Alex for the taking the leap and just seeing if something would work.

That was enough of a start to allow me to look into the enhancement and add the graphical test result support.

![Test Results](https://github.com/KronicDeth/intellij-elixir/blob/v10.4.0/screenshots/features/run_debug_configurations/mix_espec/Test Results.png?raw=true)

Graphic Test Formatter

Unlike mix test, which has a commandline --formatter flag (thanks to Jake Becker), mix espec only allows setting the formatter in an ESpec.configure block.

For projects that don’t set the config.formatters, IntelliJ Elixir can run code to set the formatter, but this code runs before the spec_helper.exs is run, so if you override the default formatters you will need to add the following code to your spec_helper.exs.

If you override formatters similar to below

ESpec.configure fn(config) ->
  config.formatters ...
ESpec.configure fn(config) ->
  config.formatters [
      {ESpec.Formatters.Json, %{out_path: "results.json"}},
      {ESpec.Formatters.Html, %{out_path: "results.html"}},
      {ESpec.Formatters.Doc, %{details: true, out_path: "results.txt"}},
      {ESpec.Formatters.Doc, %{details: true, diff_enabled?: false, out_path: "results-no-diff.txt"}},
      {ESpec.CustomFormatter, %{a: 1, b: 2}},
    ]
end

Replace them with code that checks for the graphical formatter TeamCityESpecFormatter and uses it only when available.

ESpec.configure fn(config) ->
  config.formatters(if Code.ensure_loaded?(TeamCityESpecFormatter) do
    [{TeamCityESpecFormatter, %{}}]
  else
    ...
  end)
end
ESpec.configure fn(config) ->
  config.formatters(if Code.ensure_loaded?(TeamCityESpecFormatter) do
    [{TeamCityESpecFormatter, %{}}]
  else
    [
      {ESpec.Formatters.Json, %{out_path: "results.json"}},
      {ESpec.Formatters.Html, %{out_path: "results.html"}},
      {ESpec.Formatters.Doc, %{details: true, out_path: "results.txt"}},
      {ESpec.Formatters.Doc, %{details: true, diff_enabled?: false, out_path: "results-no-diff.txt"}},
      {ESpec.CustomFormatter, %{a: 1, b: 2}},
    ]
  end)
end

Remove Unresolved Module Attribute Warning For .eex Files

IntelliJ Elixir has had a warning about unresolved module attributes since v2.0.0 (released 2016-01-06). When .eex support was added in v6.6.0 (released 2017-12-02), I knew that I needed to treat module attributes differently as they resolve to assigns keys in Phoenix, but differently for base .eex. I’ve never gotten back to implementing module attribute to assign resolution, so the module attributes in .eex templates have been falsely reporting as unresolved. I left it in as a reminder that I should fix it, but it started to annoy the users too. Thankfully, Nathan Schulzke, stepped up and made a PR to disable the “resolved module attribute” warning in .eex files for the time being, until I or someone else in the community can get around to resolving the .eex module attributes to Phoenix assigns.

Installation

You can install IntelliJ Elixir v10.4.0 from inside any of the support JetBrains IDEs. I recommend using IntelliJ IDEA (Community or Ultimate) edition if you’re using umbrella projects.

DockYard is a digital product agency offering exceptional user experience, design, full stack engineering, web app development, custom software, Ember, Elixir, and Phoenix services, consulting, and training. With a nationwide staff, we’ve got consultants in key markets across the U.S., including Portland, Los Angeles, Salt Lake City, Minneapolis, Miami, Washington D.C., and Boston.

Newsletter

Stay in the Know

Get the latest news and insights on Elixir, Phoenix, machine learning, product strategy, and more—delivered straight to your inbox.

Narwin holding a press release sheet while opening the DockYard brand kit box