Skip to content

Conversation

natebrunette
Copy link

This adds support for filtering tests in various ways

Add file/directory/module support

  • Can select anywhere in the file and run using shortcut or right click and select the menu item
  • Can also create use execute run configs by selecting a file or directory (directory will execute all tests within that directory)
  • Added gutter icon to module line to run or edit the run config using the icon

Add elm-test-rs support

  • Added a checkbox in preferences to use elm-test-rs instead of elm-test
  • Checkbox will enable testing individual test or describe functions
  • Adds gutter icons next to test or describe
  • Can test by selecting the test or describe line and using shortcut or menu
  • Can test by selecting a test body (will walk up and find the nearest test parent)
  • Will only work on tests or describes that have a string following the function

@natebrunette natebrunette force-pushed the support-elm-test-rs branch from dda2a29 to 2fb671b Compare July 16, 2025 22:34
@ahankinson
Copy link
Contributor

Thank you!

Could you add elm-test-rs to the list of npm dependencies installed for CI testing?

https://github.com/elm-tooling/intellij-elm/blob/develop/.github/workflows/build.yml#L130

You can then run the tests in the CI that require elm-test-rs.

@natebrunette
Copy link
Author

I'm not sure elm-test-rs is required for the tests I wrote, but there's also probably tests that I missed.

@natebrunette natebrunette force-pushed the support-elm-test-rs branch from 028f653 to f7b7f3e Compare July 17, 2025 14:46
@natebrunette
Copy link
Author

@ahankinson I'm noticing an issue when I built the plugin and tested it on a different machine with extremely slow loading of the settings. I think it has to do with the auto discovery code, but I wasn't seeing that when I built it and ran it on my dev machine through intellij.

@ahankinson
Copy link
Contributor

I checked out your latest code and ran it. It works fine, and I didn't notice any slowdown. I'm on an M1 Macbook Pro.

I think the UX could be improved, however.

The elm-test settings panel seems that it should be set to either elm-test or elm-test-rs, but if you set it to elm-test and check the "Use elm-test-rs?" checkbox, it does not work. It only works if you set the "elm-test" box to elm-test-rs AND click the "Use elm-test-rs?" checkbox.

Would it be possible to auto-detect the test-runner that is specified, and get rid of the checkbox? You can add a little help note that both are supported.

Your autodetection could look for the presence of "elm-test-rs" in the output of the --version command:

❯ elm-test --version
0.19.1-revision16
❯ elm-test-rs --version
elm-test-rs 3.0.1

This would also fix the issue that, if you do have something filled out in that field, clicking the checkbox will wipe it out.

Would it also be possible to print a message to the console when the testing is done? Right now I see "Testing started at 00:41 ..." but nothing to indicate that it has finished.

Other than that, it works well. I even used it to find a bug in core-extra when I was trying to find a test suite to run.

@natebrunette
Copy link
Author

There's a few things I figured out while testing

  • I use devbox on the other project, so the auto detect button was never going to work
  • The project is very large, so part of the problem is that the searching is happening on the UI thread, moving it to a different thread improves the UX both when it can find the binary and when it can't.

I originally did want to autodetect which binary is being used. It was earlier on in the development, but I couldn't figure out how to get the version in part of the code that needed it. I can take another crack at it though, now that I understand the code better. If we do go that route, what should happen when the autodetect button is clicked?

The issue you're seeing with the checkbox sounds like it's having trouble locating elm-test-rs. When you check it, it tries to find elm-test or elm-test-rs depending on the state and fill the textbox in with the path.

I haven't noticed the testing issue, how are you running the tests? That said, I have noticed that sometimes it seems like the test that walks up to find the nearest test case is running when it's not. I'll make sure and pay attention to what I'm doing when I see that next.

I also noticed that at some point using the keyboard shortcut to run a specific test broke, so I'll need to figure out what's happening there as well.

@ahankinson
Copy link
Contributor

what should happen when the autodetect button is clicked?

The auto-detect on any of the fields rarely works for me, so I generally ignore it. :-D

I would say look for elm-test first; if that isn't found, look for elm-test-rs? If you get super fancy you could alert the user to the presence of elm-test-rs and offer for them to switch to it?

When you check it, it tries to find elm-test or elm-test-rs depending on the state and fill the textbox in with the path.

I have npm installed through homebrew, and if I npm install -g elm-test or elm-test-rs it goes to /opt/homebrew/bin. This is on my path, but it never seems to auto-detect it.

I haven't noticed the testing issue, how are you running the tests?

It's not really an issue. I'm right-clicking on the test folder and clicking "run tests". It brings up a window like this:

image

The tests have stopped running, but no message is printed to let the user know that. (Well, it's there in teeny-tiny print at the top I guess...)

@natebrunette
Copy link
Author

is elm-test in node_modules/.bin? I have to npm install --save-dev elm-test-rs to get it to auto detect it. That said, the UX could be cleaned up here so it doesn't wipe out what was there if it can't find it.

@ahankinson
Copy link
Contributor

Any updates on this?

@natebrunette
Copy link
Author

I have 2 commits I haven't pushed to fix a logic issue an improve performance. The last I worked on it, I was trying to figure out why the tests aren't returning 0 when they run. For what it's worth, it's also happening on main (it's why the tests say they've started and haven't finished). I haven't removed the checkbox for elm-test-rs yet, but I was also thinking it might still be useful to be able to quickly switch between runners. Either way, I haven't gotten to that part yet.

@ahankinson
Copy link
Contributor

Thanks!

I've just released 5.1.0 to get something out the door in the JetBrains marketplace for the new plugin. You can take the time you need and we'll get this in when you're ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants