{"id":17579308,"url":"https://github.com/arichiardi/unbroken-promises","last_synced_at":"2025-10-05T01:25:23.060Z","repository":{"id":146572545,"uuid":"169022755","full_name":"arichiardi/unbroken-promises","owner":"arichiardi","description":"Tiny macro library designed for easing up ClojureScript testing of Promises.","archived":false,"fork":false,"pushed_at":"2019-02-06T00:13:06.000Z","size":41,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T15:18:02.775Z","etag":null,"topics":["clojure","clojurescript","promises"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arichiardi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-04T03:29:24.000Z","updated_at":"2020-08-01T14:57:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7bb2886-bd3d-48a6-b65a-5f8a8f922346","html_url":"https://github.com/arichiardi/unbroken-promises","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/arichiardi/unbroken-promises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arichiardi%2Funbroken-promises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arichiardi%2Funbroken-promises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arichiardi%2Funbroken-promises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arichiardi%2Funbroken-promises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arichiardi","download_url":"https://codeload.github.com/arichiardi/unbroken-promises/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arichiardi%2Funbroken-promises/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278399621,"owners_count":25980330,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clojure","clojurescript","promises"],"created_at":"2024-10-22T00:44:29.373Z","updated_at":"2025-10-05T01:25:23.037Z","avatar_url":"https://github.com/arichiardi.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClojureScript UnBroken Promises\n\nThis is a library designed for easing up ClojureScript async testing of\nPromises.\n\n[![Clojars Project](https://img.shields.io/clojars/v/unbroken-promises.svg)](https://clojars.org/unbroken-promises)\n\n```clojure\n[unbroken-promises \"0.1.9\"]\n```\n\n```clojure\nunbroken-promises {:mvn/version \"0.1.9\"}\n```\n\n### Readability and robustness\n\nTwo macros have been designed for helping with the perilous task of\n[testing async code in ClojureScript](https://clojurescript.org/tools/testing#async-testing):\n`is-resolved` and `is-rejected`.\n\nTesting `js/Promise` resolution at the moment reads:\n\n```clojure\n(deftest the-fetch-test\n  (cljs.test/async done\n    (-\u003e (fetch \"http:/foo.com/bar.json\")\n        (.then (fn [result]\n                 (is (some? result))\n                 (is (= result \"bar\"))))\n        (.then done))))\n```\n\nBut thanks to `unbroken-promises.macro` it becomes:\n\n```clojure\n(ns my-namespace-under-test\n  (:require [unbroken-promises :as ubp :include-macros true]))\n\n(deftest the-fetch-test\n  (ubp/is-resolved [result (fetch \"http:/foo.com/bar.json\")]\n    (is (some? result))\n    (is (= result \"bar\"))))\n```\n\nNot only the former is arguably cleaner but it also correctly handles the case\nwhen the promise unexpectedly rejects, reporting it as testing error.\n\nAnalogously, `unbroken-promises/is-rejected` makes sure we correctly test\nrejections:\n\n```clojure\n(deftest the-rejection-test\n  (ubp/is-rejected [err (js/Promise.reject (js/Error. \"Oh Noes!\"))]\n    (is (= \"Oh Noes!\" (.-message err)))))\n```\n\nSame convenience feature as above, in case of resolution we want a test error.\n\n### Nitty gritty details\n\nThe last thing to be aware of is that this library is also responsible of\nwriting the messages that you see in the test report.\n\nThe `context` entries, in `clojure.test` parlance, are computed by\n`unbroken-promises.data/file-and-line-before-promise`.  Some (very naive)\nheuristic tries to return the right file line/column coordinates. Please report\nany issue you encounter so that I can tweak things.\n\n---\n\n\u003e NOTE: You cannot have more than one async test per deftest form or only the first one will run.\n\nBecause of the above ClojureScript restriction **only one macro per `deftest`\nis allowed**.\n\nYou should never have more than one `is-resolved`/`is-rejected` in a `deftest`\nbecause **only the first macro** will be evaluated **silently ignoring the\nothers**.\n\n---\n\n## Unlicensed Software\n\nSee [The Unlicense](http://unlicense.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farichiardi%2Funbroken-promises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farichiardi%2Funbroken-promises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farichiardi%2Funbroken-promises/lists"}