Http unit tests. How?

Hello! What is the best way to write unit tests for httpr requests in Elm? I’ve only found this package https://package.elm-lang.org/packages/rogeriochaves/elm-testable/4.1.1/ that seems to be somewhat useful…

We’re working on introducing first-class support for this in elm-test (no ETA on completion yet), but in the meantime I’m sure others have suggestions for the here and now!

4 Likes

You could check out Elmer. It allows you to write tests that make expectations about Http requests or stub Http responses. It also allows you to do a lot of other cool stuff around describing the behavior of your app with respect to commands, tasks, subscriptions, ports.

Here’s the part of the readme that deals with describing behavior related to http requests.

Note that Elmer only supports testing with the elm/http package at version 1.0.0. I’m thinking about ways to make Elmer more modular before considering whether to extend support for the 2.0.0 version.

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