We’ve been using elm-test for a while now and have put our tests in files in the top level
tests/ directory in a hierarchy that mirrors the one in
src/ but with
Tests at the top.
I am curious to move in the same direction with Elm. Initially I felt that it wasn’t supported and that all tests should be in the
tests/ directory, however someone suggested on slack that you could add a
tests/ that imported all the test files from where they live in the
src/ hierarchy. I started to explore that and wrote a little basic script to auto-generate the
Tests.All module. This allows you to run
elm-test and for everything to still be discovered and run.
Then today, I’ve realised that you can pass files directly to
elm-test src/**/*Test.elm in order to achieve a similar result.
My questions is: what are others doing? Have you gone one way or another? Are their particular pros & cons associated with each route? I suspect there might be issues around editor integration as you need to use
elm-test make to build a test file and having the
tests/ directory is one way to detect that.