This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-17
Channels
- # announcements (1)
- # aws (40)
- # babashka (37)
- # beginners (305)
- # chlorine-clover (15)
- # cider (5)
- # cljs-dev (40)
- # clojure (62)
- # clojure-europe (13)
- # clojure-nl (4)
- # clojure-spec (10)
- # clojure-sweden (2)
- # clojure-uk (59)
- # clojurescript (9)
- # core-async (13)
- # cursive (5)
- # data-science (2)
- # datascript (2)
- # datomic (29)
- # emacs (8)
- # fulcro (58)
- # lambdaisland (9)
- # leiningen (2)
- # lumo (3)
- # mid-cities-meetup (1)
- # midje (1)
- # off-topic (28)
- # shadow-cljs (32)
- # spacemacs (3)
- # sql (5)
- # tools-deps (1)
- # tree-sitter (1)
- # vscode (2)
- # yada (2)
with Clojurescript’s async
test macro, how do I test that a promise is rejected?
found an example in promesas docs
(t/deftest promise-from-exception
#?(:clj
(let [e (ex-info "foo" {})
p1 (p/promise e)]
(t/is (p/rejected? p1))
(t/is (= e @@(p/catch p1 (fn [x] (reduced x))))))
:cljs
(t/async done
(let [e (ex-info "foo" {})
p1 (p/promise e)]
;; (t/is (p/rejected? p1))
(p/catch p1 (fn [x]
(t/is (= e x))
(done)))))))
i'm trying to write tests for some browser-targeted CLJS code. the code i'd like to test operates on a 2MB file; that's too much to inline somewhere, so i'd like to read that data from a file in my project dir and use it in my CLJS test.
i sort of understand that i'm barking up the wrong tree trying to read in a file from disk in browser-targeted CLJS, because the browser has no such capabilities.
i've seen examples where people use clojure's slurp at compile time, but i haven't been able to get any of those examples working for myself.
i'd also really like to avoid serving the file from a local HTTP server; that seems ridiculously heavy for this purpose, and i would love for there to be some simpler solution.
If that's just for tests, then it should be perfectly fine to inline the data. All the examples that slurp the data during compile time do exactly that. This is relevant, if you use shadow-cljs: https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745