An elegant way to expose doctests to elm-test?

I’ve some doctests for elm functions which I’m exposing in the module statement.
How are you doing this and making it clear the functions are only being exposed for elm-test (and elm-verify-examples)?

Or do you not test such internal functions and only test the public API so that refactors are unhindered?


No matter what language I’m using, I test only public APIs.

1 Like

instead of exposing the function, I put it into a test record and expose that instead

 module Example exposing
     ( func
-    , helper
+    , test
+test =
+    { helper = helper
+    }

then I add test. prefix in my tests

-    helper "k"
+    test.helper "k"
     --> False
-    helper " "
+    test.helper " "
     --> True

In theory, you could have an elm-review rule that test records are not accessed outside of test code


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.