Run elm-test from within IntelliJ.
This is useful if you want the convenience of running elm-test
from a GUI with green and red lights for each test, indicating success and failure respectively.
Enabling this feature has no significant performance implications beyond the work that elm-test
itself does to run your tests.
- Open IntelliJ Settings
- Select Languages & Frameworks from the left-side pane
- Select Elm
- Fill out the section titled elm-test (use the Auto Discover button to search common locations)
Once you have configured the path to elm-test
(see above), right-click anywhere within an Elm file and select Run (Tests in $YourProjectName).
By default, elm-test
expects unit tests to exist in a folder called tests
at the root of the Elm project, i.e. as a
sibling of elm.json
. For application projects (as opposed to package projects) using Elm 19 (or later) a custom
location can be used, as discussed here.
In order for the Elm plugin to take advantage of this feature, the custom location must be specified as follows:
-
Create a file called
elm.intellij.json
as a sibling ofelm.json
. -
Populate this file with the following content:
{ "test-directory": "..." }
The value for
test-directory
should be the path to the folder containing the unit tests, relative toelm.json
, e.g.src/test/elm
. This folder can contain subfolders - all tests anywhere under this folder will be executed. -
Update
elm.json
and add the value you used fortest-directory
above to thesource-directories
array.
As mentioned above, note that this only works for applications, not packages, i.e. only for projects where elm.json
has a type
field with a value of application
.