{"id":17795842,"url":"https://github.com/avh4/elm-testable","last_synced_at":"2025-03-17T00:33:46.654Z","repository":{"id":57674825,"uuid":"57188663","full_name":"avh4/elm-testable","owner":"avh4","description":"Makes Cmds and Tasks testable","archived":false,"fork":false,"pushed_at":"2021-05-26T20:45:37.000Z","size":338,"stargazers_count":41,"open_issues_count":7,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-11T13:51:15.210Z","etag":null,"topics":["deprecated","elm","testing"],"latest_commit_sha":null,"homepage":"http://package.elm-lang.org/packages/avh4/elm-testable/latest","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avh4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-27T06:20:10.000Z","updated_at":"2023-02-07T12:47:04.000Z","dependencies_parsed_at":"2022-09-14T17:11:54.297Z","dependency_job_id":null,"html_url":"https://github.com/avh4/elm-testable","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avh4%2Felm-testable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avh4%2Felm-testable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avh4%2Felm-testable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avh4%2Felm-testable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avh4","download_url":"https://codeload.github.com/avh4/elm-testable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deprecated","elm","testing"],"created_at":"2024-10-27T11:39:00.012Z","updated_at":"2025-03-17T00:33:45.143Z","avatar_url":"https://github.com/avh4.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Deprecated\n\nNow use [avh4/elm-program-test](https://elm-program-test.netlify.app) instead.  (elm-testable only works with ELm 0.17)\n\n## ~~Note:~~\n\n~~elm-testable does not support Elm 0.18.  A new package is currently in development that will allow testing of Cmds, Tasks, and Subs without the need for elm-testable's wrappers.  More details will be posted to elm-discuss when it is available.  (See the [rewrite-native branch](https://github.com/avh4/elm-testable/tree/rewrite-native).)~~\n\n[![Build Status](https://travis-ci.org/avh4/elm-testable.svg?branch=master)](https://travis-ci.org/avh4/elm-testable)\n\n# avh4/elm-testable\n\nThis package allows you to write components that follow the Elm Architecture in a way that is testable.\nTo allow this, elm-testable provides testable versions of the `Task`, `Effects`, and `Http` modules,\nas well as `Testable.TestContext` to test testable components and `Testable` to integrate testable components with your Elm app.\n\n\n## Example testable component\n\nThe only difference between a testable component and a standard component is the added `Testable.` in several imports.  (With the exception of `Cmd`, which conflicts with the default import of `Platform.Cmd` in Elm 0.17.)\n\nHere is the diff of converting `RandomGif.elm` into a testable component:\n\n```diff\ndiff --git b/examples/RandomGif.elm a/examples/RandomGif.elm\n@@ -6,8 +6,9 @@ import Html exposing (..)\n import Json.Decode as Json\n-import Http\n-import Task\n+import Testable.Cmd\n+import Testable.Http as Http\n+import Testable.Task as Task\n \n @ -20,7 +21,7 @@ type alias Model =\n\n-init : String -\u003e String -\u003e ( Model, Cmd Msg )\n+init : String -\u003e String -\u003e ( Model, Testable.Cmd.Cmd Msg )\n init apiKey topic =\n@@ -36,7 +37,7 @@ type Msg\n \n-update : Msg -\u003e Model -\u003e ( Model, Cmd Msg )\n+update : Msg -\u003e Model -\u003e ( Model, Testable.Cmd.Cmd Msg )\n update msg model =\n@@ -44,7 +45,7 @@ update msg model =\n             ( Model model.apiKey model.topic (Maybe.withDefault model.gifUrl maybeUrl)\n-            , Cmd.none\n+            , Testable.Cmd.none\n             )\n@@ -89,7 +90,7 @@ imgStyle url =\n \n-getRandomGif : String -\u003e String -\u003e Cmd Msg\n+getRandomGif : String -\u003e String -\u003e Testable.Cmd.Cmd Msg\n getRandomGif apiKey topic =\n     Http.get decodeUrl (randomUrl apiKey topic)\n         |\u003e Task.perform (always Nothing \u003e\u003e NewGif)\ndiff --git b/examples/Main.elm a/examples/Main.elm\n@@ -3,12 +3,13 @@ module Main exposing (..)\n import Task\n+import Testable\n \n main =\n     Html.App.program\n-        { init = init \"__API_KEY__\" \"funny cats\"\n-        , update = update\n+        { init = Testable.init \u003c| init \"__API_KEY__\" \"funny cats\"\n+        , update = Testable.update update\n         , view = view\n```\n\n\n## Example tests\n\nHere is an example of the types of tests you can write for testable components:\n\n```elm\nimport ElmTest exposing (..)\nimport Testable.TestContext exposing (..)\nimport Testable.Effects as Effects\nimport Testable.Http as Http\n\n\nmyComponent =\n    { init = MyComponent.init\n    , update = MyComponent.update\n    }\n\n\nall : Test\nall =\n    suite \"MyComponent\"\n        [ myComponent\n            |\u003e startForTest\n            |\u003e currentModel\n            |\u003e assertEqual (Ok expectedModelValue)\n            |\u003e test \"sets initial state\"\n        , myComponent\n            |\u003e startForTest\n            |\u003e assertHttpRequest (Http.getRequest \"https://example.com/myResource\")\n            |\u003e test \"makes initial HTTP request\"\n        , myComponent\n            |\u003e startForTest\n            |\u003e resolveHttpRequest (Http.getRequest \"https://example.com/myResource\")\n                (Http.ok \"\"\"{\"data\":\"example JSON response\"}\"\"\")\n            |\u003e assertEqual (Ok expectedModelValue)\n            |\u003e test \"updated the model on HTTP success\"\n        , myComponent\n            |\u003e startForTest\n            |\u003e update (MyComponent.LoadDetails 1234)\n            |\u003e assertHttpRequest (Http.getRequest \"https://example.com/myResource/1234\")\n            |\u003e test \"pressing the button makes a new HTTP request\"\n        ]\n```\n\nHere are [complete tests for the RandomGif example](https://github.com/avh4/elm-testable/blob/master/examples/tests/RandomGifTests.elm).\n\n\n## Example integration with `Main`\n\nTo convert your testable `view` and `update` functions into functions that work with `StartApp`, use the `Testable` module:\n\n```elm\nmain : Program Never\nmain =\n    Html.App.program\n        { init = Testable.init MyComponent.init\n        , update = Testable.update MyComponent.update\n        , view = MyComponent.view\n        , subscriptions = MyComponent.subscriptions\n        }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favh4%2Felm-testable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favh4%2Felm-testable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favh4%2Felm-testable/lists"}