I just watched a Twitch stream[1] of avh4 where he mentions shortly at end that it’s been planned to add testing of Commands and Tasks to elm-explorations/test, basically what he did earlier in avh4/elm-testable.
So it seems there isn’t a way to do this currently (at least I havn’t found any), but it might be added later.
I’d encourage you to think less about unit-testing individual functions and more about using tests to describe the behavior of your program at a higher level.
For example, instead of testing that some particular function returns the right Task, maybe you want to test that your program displays some information when some response to an Http request is received. The implementation might involve a function that returns a Task (if you’re using Http.toTask) but that’s just a detail. If you could write a test that describes how your software should work at a high level without knowledge of such details, then you’d (1) be sure that your software does the right thing and (2) give yourself freedom to refactor your code later without changing your tests. Maybe tomorrow you decide that you no longer need to use Http.toTask. If you write tests that describe behavior instead of implementation details, you could make that change, run your tests and – if they pass – feel confident that your software still has all the behavior you’ve described in those tests.
I know of two ways to do this today with Elm.
Run your Elm program and write a test that interacts with your program purely through the DOM – ie treat your Elm program like a black box from the perspective of your tests. You could do this in several ways. Start your app so that you can visit it with a web browser; write a test (in Jasmine or Mocha/Chai) that drives the web browser (with Pupeteer) and makes relevent expectations. Or, run your tests (written in Jasmine or Mocha/Chai) with Karma so you have access to a DOM, mount your Elm Program before each test, then use DOM functions to exercise it and make expectations.
You could use Elmer to write tests in Elm that describe the behavior of your app. (Disclaimer: I wrote Elmer.) Elmer allows you to stub Cmd and Sub values (and ports) so that you can simulate conditions under which you want to describe the behavior of your program.